PHP Класс Cake\Chronos\ChronosInterval

The implementation provides helpers to handle weeks but only days are saved. Weeks are calculated based on the total days of the current instance.
Наследование: extends DateInterva\DateInterval
Показать файл Открыть проект Примеры использования класса

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

Свойство Тип Описание
$isHHVM boolean Whether or not this object was created in HHVM

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

Метод Описание
__call ( string $name, array $args ) : static Allow fluent calls on the setters.
__callStatic ( string $name, array $args ) : static Provide static helpers to create instances. Allows:
__construct ( integer | null $years = 1, integer | null $months = null, integer | null $weeks = null, integer | null $days = null, integer | null $hours = null, integer | null $minutes = null, integer | null $seconds = null ) Create a new ChronosInterval instance.
__get ( string $name ) : integer Get a part of the ChronosInterval object
__set ( string $name, integer $val ) : void Set a part of the ChronosInterval object
__toString ( ) : string Returns the ISO 8601 interval string.
add ( DateInterval $interval ) : static Add the passed interval to the current instance
create ( integer | null $years = 1, integer | null $months = null, integer | null $weeks = null, integer | null $days = null, integer | null $hours = null, integer | null $minutes = null, integer | null $seconds = null ) : static Create a new ChronosInterval instance from specific values.
instance ( DateInterval $di ) : static Create a ChronosInterval instance from a DateInterval one. Can not instance DateInterval objects created from DateTime::diff() as you can't externally set the $days field.
weeksAndDays ( integer $weeks, integer $days ) : static Allow setting of weeks and days to be cumulative.

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

Метод Описание
wasCreatedFromDiff ( DateInterval $interval ) : boolean Determine if the interval was created via DateTime:diff() or not.

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

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

.. ChronosInterval::years(3)->months(5)->day(). Note: This is done using the magic method to allow static and instance methods to have the same names.
public __call ( string $name, array $args ) : static
$name string The property name to augment. Accepts plural forms in addition to singular ones.
$args array The value to set.
Результат static

__callStatic() публичный статический Метод

ChronosInterval::years(3) or ChronosInterval::month(1); Note: This is done using the magic method to allow static and instance methods to have the same names.
public static __callStatic ( string $name, array $args ) : static
$name string The property to configure. Accepts singular and plural forms.
$args array Contains the value to use.
Результат static

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

Create a new ChronosInterval instance.
public __construct ( integer | null $years = 1, integer | null $months = null, integer | null $weeks = null, integer | null $days = null, integer | null $hours = null, integer | null $minutes = null, integer | null $seconds = null )
$years integer | null The year to use.
$months integer | null The month to use.
$weeks integer | null The week to use.
$days integer | null The day to use.
$hours integer | null The hours to use.
$minutes integer | null The minutes to use.
$seconds integer | null The seconds to use.

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

Get a part of the ChronosInterval object
public __get ( string $name ) : integer
$name string The property to read.
Результат integer

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

Set a part of the ChronosInterval object
public __set ( string $name, integer $val ) : void
$name string The property to augment.
$val integer The value to change.
Результат void

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

Returns the ISO 8601 interval string.
public __toString ( ) : string
Результат string Interval as string representation

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

Add the passed interval to the current instance
public add ( DateInterval $interval ) : static
$interval DateInterval The interval to add.
Результат static

create() публичный статический Метод

This is an alias for the constructor that allows better fluent syntax as it allows you to do ChronosInterval::create(1)->fn() rather than (new ChronosInterval(1))->fn().
public static create ( integer | null $years = 1, integer | null $months = null, integer | null $weeks = null, integer | null $days = null, integer | null $hours = null, integer | null $minutes = null, integer | null $seconds = null ) : static
$years integer | null The year to use.
$months integer | null The month to use.
$weeks integer | null The week to use.
$days integer | null The day to use.
$hours integer | null The hours to use.
$minutes integer | null The minutes to use.
$seconds integer | null The seconds to use.
Результат static

instance() публичный статический Метод

Create a ChronosInterval instance from a DateInterval one. Can not instance DateInterval objects created from DateTime::diff() as you can't externally set the $days field.
public static instance ( DateInterval $di ) : static
$di DateInterval The DateInterval instance to copy.
Результат static

wasCreatedFromDiff() защищенный статический Метод

Determine if the interval was created via DateTime:diff() or not.
protected static wasCreatedFromDiff ( DateInterval $interval ) : boolean
$interval DateInterval The interval to check.
Результат boolean

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

Allow setting of weeks and days to be cumulative.
public weeksAndDays ( integer $weeks, integer $days ) : static
$weeks integer Number of weeks to set
$days integer Number of days to set
Результат static

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

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

Whether or not this object was created in HHVM
protected bool $isHHVM
Результат boolean