Skip to content

Commit

Permalink
Merge pull request #17 from Danubio/master
Browse files Browse the repository at this point in the history
Portugal Holidays
  • Loading branch information
Florian Körner authored Dec 19, 2016
2 parents 6dbb610 + ce15906 commit fba86aa
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 0 deletions.
44 changes: 44 additions & 0 deletions lib/Checkdomain/Holiday/Provider/PT.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

namespace Checkdomain\Holiday\Provider;

/**
* Portugal holiday provider
*
* @author Tiago Carvalho <[email protected]>
*/
class PT extends AbstractEaster
{

/**
* @param int $year
*
* @return mixed
*/
public function getHolidaysByYear($year)
{
$easter = $this->getEasterDates($year);

$holidays = array(
'01-01' => $this->createData('Ano Novo'),
'04-25' => $this->createData('25 de Abril'),
'05-01' => $this->createData('Dia do Trabalhador'),
'06-10' => $this->createData('Dia de Portugal'),
'08-15' => $this->createData('Assunção de Nossa Senhora'),
'12-08' => $this->createData('Dia da Imaculada Conceição'),
'12-25' => $this->createData('Natal'),
// Variable dates
$easter['goodFriday']->format(self::DATE_FORMAT) => $this->createData('Sexta-Feira Santa'),
$easter['easterSunday']->format(self::DATE_FORMAT) => $this->createData('Páscoa'),
);
//add holidays post 2015
if ($year >= 2016) {
$holidays['05-26'] = $this->createData('Corpo de Deus');
$holidays['10-05'] = $this->createData('Implantação da República');
$holidays['11-01'] = $this->createData('Dia de Todos os Santos');
$holidays['12-01'] = $this->createData('Restauração da Independência');
}

return $holidays;
}
}
50 changes: 50 additions & 0 deletions tests/Checkdomain/Holiday/Provider/PTTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php
/**
* Portuguese holiday provider
*
* @author Tiago Carvalho <[email protected]>
*/
namespace Checkdomain\Holiday\Provider;

/**
* Class PTTest
*/
class PTTest extends AbstractTest
{
/**
* {@inheritDoc}
*/
public function setUp()
{
$this->provider = new PT();
}

/**
* Provides some test dates and the expectation
*
* @return array
*/
public function dateProvider()
{
return array(
array('01.01.2010', null, array('name' => 'Ano Novo')),

array('26.05.2013', null, null),
array('25.04.2013', null, array('name' => '25 de Abril')),

array('05.10.2014', null, null),
array('01.05.2014', null, array('name' => 'Dia do Trabalhador')),

array('01.12.2015', null, null),
array('15.08.2015', null, array('name' => 'Assunção de Nossa Senhora')),

array('02.01.2016', null, null),
array('01.11.2016', null, array('name' => 'Dia de Todos os Santos')),
array('25.12.2016', null, array('name' => 'Natal')),

array('03.09.2017', null, null),
array('01.12.2017', null, array('name' => 'Restauração da Independência')),
array('10.06.2017', null, array('name' => 'Dia de Portugal')),
);
}
}

0 comments on commit fba86aa

Please sign in to comment.