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

1
2
3
4
5
6
7
8
9
10
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);
}
doc_Drupal
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.