public function DateTimePlus::__call

public DateTimePlus::__call($method, $args)

Implements the magic __call method.

Passes through all unknown calls onto the DateTime object.

File

core/lib/Drupal/Component/Datetime/DateTimePlus.php, line 304

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);
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Component!Datetime!DateTimePlus.php/function/DateTimePlus::__call/8.1.x