PHP Class Yasumi\Holiday

Inheritance: extends DateTim\DateTime, implements JsonSerializabl\JsonSerializable
ファイルを表示 Open project: azuyalabs/yasumi Class Usage Examples

Public Properties

Property Type Description
$shortName short name (internal name) of this holiday
$translations list of translations of this holiday

Public Methods

Method Description
__construct ( string $shortName, array $names, DateTime $date, string $displayLocale = self::DEFAULT_LOCALE, string $type = self::TYPE_NATIONAL ) Creates a new Holiday.
__toString ( ) : string Format the instance as a string using the set format.
getName ( ) Returns the name of this holiday.
getType ( ) : string Returns what type this holiday is.
jsonSerialize ( ) Serializes the object to a value that can be serialized natively by json_encode().
mergeGlobalTranslations ( yasumi\TranslationsInterface $globalTranslations ) Merges local translations (preferred) with global translations.

Method Details

__construct() public method

If a holiday date needs to be defined for a specific timezone, make sure that the date instance (DateTime) has the correct timezone set. Otherwise the default system timezone is used.
public __construct ( string $shortName, array $names, DateTime $date, string $displayLocale = self::DEFAULT_LOCALE, string $type = self::TYPE_NATIONAL )
$shortName string The short name (internal name) of this holiday
$names array An array containing the name/description of this holiday in various languages. Overrides global translations
$date DateTime A DateTime instance representing the date of the holiday
$displayLocale string Locale (i.e. language) in which the holiday information needs to be displayed in. (Default 'en_US')
$type string The type of holiday. Use the following constants: TYPE_NATIONAL, TYPE_OBSERVANCE, TYPE_SEASON, TYPE_BANK or TYPE_OTHER. By default a national holiday is considered.

__toString() public method

Format the instance as a string using the set format.
public __toString ( ) : string
return string

getName() public method

The name of this holiday is returned translated in the given locale. If for the given locale no translation is defined, the name in the default locale ('en_US') is returned. In case there is no translation at all, the short internal name is returned.
public getName ( )

getType() public method

Returns what type this holiday is.
public getType ( ) : string
return string the type of holiday (national, observance, season or bank).

jsonSerialize() public method

Serializes the object to a value that can be serialized natively by json_encode().
public jsonSerialize ( )

mergeGlobalTranslations() public method

Merges local translations (preferred) with global translations.
public mergeGlobalTranslations ( yasumi\TranslationsInterface $globalTranslations )
$globalTranslations yasumi\TranslationsInterface global translations

Property Details

$shortName public_oe property

short name (internal name) of this holiday
public $shortName

$translations public_oe property

list of translations of this holiday
public $translations