You are here

public function PersistentObject::__call in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/doctrine/common/lib/Doctrine/Common/Persistence/PersistentObject.php \Doctrine\Common\Persistence\PersistentObject::__call()

Magic methods.

Parameters

string $method:

array $args:

Return value

mixed

Throws

\BadMethodCallException

File

vendor/doctrine/common/lib/Doctrine/Common/Persistence/PersistentObject.php, line 240

Class

PersistentObject
PersistentObject base class that implements getter/setter methods for all mapped fields and associations by overriding __call.

Namespace

Doctrine\Common\Persistence

Code

public function __call($method, $args) {
  $command = substr($method, 0, 3);
  $field = lcfirst(substr($method, 3));
  if ($command == "set") {
    $this
      ->set($field, $args);
  }
  else {
    if ($command == "get") {
      return $this
        ->get($field);
    }
    else {
      if ($command == "add") {
        $this
          ->add($field, $args);
      }
      else {
        throw new \BadMethodCallException("There is no method " . $method . " on " . $this->cm
          ->getName());
      }
    }
  }
}