PHP Класс Yasumi\Provider\AbstractProvider

Наследование: implements Yasumi\ProviderInterface, implements Countabl\Countable, implements IteratorAggregat\IteratorAggregate
Показать файл Открыть проект

Защищенные свойства (Protected)

Свойство Тип Описание
$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

Открытые методы

Метод Описание
__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?

Защищенные методы

Метод Описание
clearHolidays ( ) Clear all holidays.
isHolidayNameNotEmpty ( $shortName ) : true Checks whether the given holiday (short name) is not empty.

Приватные методы

Метод Описание
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.

Описание методов

__construct() публичный Метод

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() публичный Метод

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() публичный Метод

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
Результат Yasumi\Filters\BetweenFilter

clearHolidays() защищенный Метод

Clear all holidays.
protected clearHolidays ( )

count() публичный Метод

Returns the number of defined holidays (for the given country and the given year).
public count ( ) : integer
Результат integer number of holidays

getHoliday() публичный Метод

Retrieves the holiday object for the given holiday.
public getHoliday ( $shortName ) : Holiday
$shortName string the name of the holiday.
Результат Yasumi\Holiday a Holiday instance for the given holiday

getHolidayDates() публичный Метод

Gets all of the holiday dates defined by this holiday provider (for the given year).
public getHolidayDates ( ) : array
Результат array list of all holiday dates defined for the given year

getHolidayNames() публичный Метод

Gets all of the holiday names defined by this holiday provider (for the given year).
public getHolidayNames ( ) : array
Результат array list of all holiday names defined for the given year

getHolidays() публичный Метод

Gets all of the holidays defined by this holiday provider (for the given year).
public getHolidays ( ) : Holiday[]
Результат Yasumi\Holiday[] list of all holidays defined for the given year

getIterator() публичный Метод

Get an iterator for the holidays.
public getIterator ( ) : ArrayIterator
Результат ArrayIterator iterator for the holidays of this calendar

getYear() публичный Метод

Returns the current year set for this Holiday calendar.
public getYear ( ) : integer
Результат integer the year set for this Holiday calendar

isHoliday() публичный Метод

Determines whether a date represents a holiday or not.
public isHoliday ( mixed $date ) : boolean
$date mixed a Yasumi\Holiday or DateTime object
Результат boolean true if date represents a holiday, otherwise false

isHolidayNameNotEmpty() защищенный Метод

Checks whether the given holiday (short name) is not empty.
protected isHolidayNameNotEmpty ( $shortName ) : true
$shortName string the name of the holiday to be checked.
Результат true upon success, otherwise an InvalidArgumentException is thrown

isWorkingDay() публичный Метод

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
Результат boolean true if date represents a working day, otherwise false

next() публичный Метод

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.
Результат Yasumi\Holiday a Holiday instance for the given holiday

previous() публичный Метод

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.
Результат Yasumi\Holiday a Holiday instance for the given holiday

whatWeekDayIs() публичный Метод

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
Результат integer the index of the weekdays of the requested holiday (0 = Sunday, 1 = Monday, etc.)

whenIs() публичный Метод

On what date is the given holiday?
public whenIs ( string $shortName ) : string
$shortName string short name of the holiday
Результат string the date of the requested holiday

Описание свойств

$locale защищенное свойство

the object's current locale
protected $locale

$timezone защищенное свойство

the object's current timezone
protected $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.)
protected $weekend_days

$year защищенное свойство

the object's current year
protected $year