PHP Class 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.
Inheritance: extends DateInterva\DateInterval
Afficher le fichier Open project: cakephp/chronos Class Usage Examples

Protected Properties

Свойство Type Description
$isHHVM boolean Whether or not this object was created in HHVM

Méthodes publiques

Méthode Description
__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.

Méthodes protégées

Méthode Description
wasCreatedFromDiff ( DateInterval $interval ) : boolean Determine if the interval was created via DateTime:diff() or not.

Method Details

__call() public méthode

.. 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.
Résultat static

__callStatic() public static méthode

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.
Résultat static

__construct() public méthode

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() public méthode

Get a part of the ChronosInterval object
public __get ( string $name ) : integer
$name string The property to read.
Résultat integer

__set() public méthode

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.
Résultat void

__toString() public méthode

Returns the ISO 8601 interval string.
public __toString ( ) : string
Résultat string Interval as string representation

add() public méthode

Add the passed interval to the current instance
public add ( DateInterval $interval ) : static
$interval DateInterval The interval to add.
Résultat static

create() public static méthode

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.
Résultat static

instance() public static méthode

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.
Résultat static

wasCreatedFromDiff() protected static méthode

Determine if the interval was created via DateTime:diff() or not.
protected static wasCreatedFromDiff ( DateInterval $interval ) : boolean
$interval DateInterval The interval to check.
Résultat boolean

weeksAndDays() public méthode

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
Résultat static

Property Details

$isHHVM protected_oe property

Whether or not this object was created in HHVM
protected bool $isHHVM
Résultat boolean