You are here

public function DateTimePlus::__call in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Component/Datetime/DateTimePlus.php \Drupal\Component\Datetime\DateTimePlus::__call()

Implements the magic __call method.

Passes through all unknown calls onto the DateTime object.

File

core/lib/Drupal/Component/Datetime/DateTimePlus.php, line 290
Contains \Drupal\Component\Datetime\DateTimePlus.

Class

DateTimePlus
Wraps DateTime().

Namespace

Drupal\Component\Datetime

Code

public function __call($method, $args) {

  // @todo consider using assert() as per https://www.drupal.org/node/2451793.
  if (!isset($this->dateTimeObject)) {
    throw new \Exception('DateTime object not set.');
  }
  if (!method_exists($this->dateTimeObject, $method)) {
    throw new \BadMethodCallException(sprintf('Call to undefined method %s::%s()', get_class($this), $method));
  }
  return call_user_func_array(array(
    $this->dateTimeObject,
    $method,
  ), $args);
}