You are here

public function PersistentObject::__call in Plug 7

Magic methods.

Parameters

string $method:

array $args:

Return value

mixed

Throws

\BadMethodCallException

File

lib/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());
      }
    }
  }
}