PHP Class Yasumi\Provider\AbstractProvider

Inheritance: implements Yasumi\ProviderInterface, implements Countabl\Countable, implements IteratorAggregat\IteratorAggregate
Mostrar archivo Open project: azuyalabs/yasumi

Protected Properties

Property Type Description
$locale the object's current locale
$timezone the object's current timezone
$weekend_days list of the days of the week (the index of the weekdays) that are considered weekend days. Defaults to Sunday (0) and Saturday (6), as this is globally the common standard. (0 = Sunday, 1 = Monday, etc.)
$year the object's current year

Public Methods

Method Description
__construct ( integer $year, string $locale = 'en_US', Yasumi\TranslationsInterface $globalTranslations = null ) Creates a new holiday provider (i.e. country/state).
addHoliday ( Holiday $holiday ) Adds a holiday to the holidays providers (i.e. country/state) list of holidays.
between ( DateTime $start_date, DateTime $end_date = null, boolean $equals = true ) : BetweenFilter Retrieves a list of all holidays between the given start and end date.
count ( ) : integer Returns the number of defined holidays (for the given country and the given year).
getHoliday ( $shortName ) : Holiday Retrieves the holiday object for the given holiday.
getHolidayDates ( ) : array Gets all of the holiday dates defined by this holiday provider (for the given year).
getHolidayNames ( ) : array Gets all of the holiday names defined by this holiday provider (for the given year).
getHolidays ( ) : Holiday[] Gets all of the holidays defined by this holiday provider (for the given year).
getIterator ( ) : ArrayIterator Get an iterator for the holidays.
getYear ( ) : integer Returns the current year set for this Holiday calendar.
isHoliday ( mixed $date ) : boolean Determines whether a date represents a holiday or not.
isWorkingDay ( mixed $date ) : boolean Determines whether a date represents a working day or not.
next ( $shortName ) : Holiday Retrieves the next date (year) the given holiday is going to take place.
previous ( $shortName ) : Holiday Retrieves the previous date (year) the given holiday took place.
whatWeekDayIs ( string $shortName ) : integer On what day of the week is the given holiday?
whenIs ( string $shortName ) : string On what date is the given holiday?

Protected Methods

Method Description
clearHolidays ( ) Clear all holidays.
isHolidayNameNotEmpty ( $shortName ) : true Checks whether the given holiday (short name) is not empty.

Private Methods

Method Description
anotherTime ( integer $year, string $shortName ) : Holiday Determines the date of the given holiday for another year.
compareDates ( $dateA, $dateB ) : integer Internal function to compare dates in order to sort them chronologically.

Method Details

__construct() public method

Creates a new holiday provider (i.e. country/state).
public __construct ( integer $year, string $locale = 'en_US', Yasumi\TranslationsInterface $globalTranslations = null )
$year integer the year for which to provide holidays
$locale string the locale/language in which holidays need to be represented
$globalTranslations Yasumi\TranslationsInterface global translations

addHoliday() public method

Adds a holiday to the holidays providers (i.e. country/state) list of holidays.
public addHoliday ( Holiday $holiday )
$holiday Yasumi\Holiday Holiday instance (representing a holiday) to be added to the internal list of holidays of this country.

between() public method

Yasumi only calculates holidays for a single year, so a start date or end date beyond the given year will only return holidays for the given year. For example, holidays calculated for the year 2016, will only return 2016 holidays if the provided period is for example 01/01/2012 - 31/12/2017. Please take care to use the appropriate timezone for the start and end date parameters. In case you use different timezone for these parameters versus the instantiated Holiday Provider, the outcome might be unexpected (but correct).
public between ( DateTime $start_date, DateTime $end_date = null, boolean $equals = true ) : BetweenFilter
$start_date DateTime Start date of the time frame to check against
$end_date DateTime End date of the time frame to check against
$equals boolean indicate whether the start and end dates should be included in the comparison
return Yasumi\Filters\BetweenFilter

clearHolidays() protected method

Clear all holidays.
protected clearHolidays ( )

count() public method

Returns the number of defined holidays (for the given country and the given year).
public count ( ) : integer
return integer number of holidays

getHoliday() public method

Retrieves the holiday object for the given holiday.
public getHoliday ( $shortName ) : Holiday
$shortName string the name of the holiday.
return Yasumi\Holiday a Holiday instance for the given holiday

getHolidayDates() public method

Gets all of the holiday dates defined by this holiday provider (for the given year).
public getHolidayDates ( ) : array
return array list of all holiday dates defined for the given year

getHolidayNames() public method

Gets all of the holiday names defined by this holiday provider (for the given year).
public getHolidayNames ( ) : array
return array list of all holiday names defined for the given year

getHolidays() public method

Gets all of the holidays defined by this holiday provider (for the given year).
public getHolidays ( ) : Holiday[]
return Yasumi\Holiday[] list of all holidays defined for the given year

getIterator() public method

Get an iterator for the holidays.
public getIterator ( ) : ArrayIterator
return ArrayIterator iterator for the holidays of this calendar

getYear() public method

Returns the current year set for this Holiday calendar.
public getYear ( ) : integer
return integer the year set for this Holiday calendar

isHoliday() public method

Determines whether a date represents a holiday or not.
public isHoliday ( mixed $date ) : boolean
$date mixed a Yasumi\Holiday or DateTime object
return boolean true if date represents a holiday, otherwise false

isHolidayNameNotEmpty() protected method

Checks whether the given holiday (short name) is not empty.
protected isHolidayNameNotEmpty ( $shortName ) : true
$shortName string the name of the holiday to be checked.
return true upon success, otherwise an InvalidArgumentException is thrown

isWorkingDay() public method

A working day is defined as a day that is not a holiday nor falls in the weekend. The index of the weekdays of the defined date is used for establishing this (0 = Sunday, 1 = Monday, etc.)
public isWorkingDay ( mixed $date ) : boolean
$date mixed a Yasumi\Holiday or DateTime object
return boolean true if date represents a working day, otherwise false

next() public method

Retrieves the next date (year) the given holiday is going to take place.
public next ( $shortName ) : Holiday
$shortName string the name of the holiday for which the next occurrence need to be retrieved.
return Yasumi\Holiday a Holiday instance for the given holiday

previous() public method

Retrieves the previous date (year) the given holiday took place.
public previous ( $shortName ) : Holiday
$shortName string the name of the holiday for which the previous occurrence need to be retrieved.
return Yasumi\Holiday a Holiday instance for the given holiday

whatWeekDayIs() public method

This function returns the index number for the day of the week on which the given holiday falls. The index number is an integer starting with 0 being Sunday, 1 = Monday, etc.
public whatWeekDayIs ( string $shortName ) : integer
$shortName string short name of the holiday
return integer the index of the weekdays of the requested holiday (0 = Sunday, 1 = Monday, etc.)

whenIs() public method

On what date is the given holiday?
public whenIs ( string $shortName ) : string
$shortName string short name of the holiday
return string the date of the requested holiday

Property Details

$locale protected_oe property

the object's current locale
protected $locale

$timezone protected_oe property

the object's current timezone
protected $timezone

$weekend_days protected_oe property

list of the days of the week (the index of the weekdays) that are considered weekend days. Defaults to Sunday (0) and Saturday (6), as this is globally the common standard. (0 = Sunday, 1 = Monday, etc.)
protected $weekend_days

$year protected_oe property

the object's current year
protected $year