You are here

public static function CarbonInterval::__callStatic in Persian Date for Drupal 8 8.4

Provide static helpers to create instances. Allows CarbonInterval::years(3).

Note: This is done using the magic method to allow static and instance methods to have the same names.

Parameters

string $name:

array $args:

Return value

static

File

src/Library/Carbon/CarbonInterval.php, line 180

Class

CarbonInterval
A simple API extension for DateInterval. The implementation provides helpers to handle weeks but only days are saved. Weeks are calculated based on the total days of the current instance.

Namespace

Drupal\persian_date\Library\Carbon

Code

public static function __callStatic($name, $args) {
  $arg = count($args) === 0 ? 1 : $args[0];
  switch ($name) {
    case 'years':
    case 'year':
      return new static($arg);
    case 'months':
    case 'month':
      return new static(null, $arg);
    case 'weeks':
    case 'week':
      return new static(null, null, $arg);
    case 'days':
    case 'dayz':
    case 'day':
      return new static(null, null, null, $arg);
    case 'hours':
    case 'hour':
      return new static(null, null, null, null, $arg);
    case 'minutes':
    case 'minute':
      return new static(null, null, null, null, null, $arg);
    case 'seconds':
    case 'second':
      return new static(null, null, null, null, null, null, $arg);
  }
}