/** * @param string $name * @param array $arguments * @return mixed * @throws \Exception */ private function __handleCall($name, array $arguments) { if (false === $this->__initProps) { $this->__initProps = true; $this->_initProps(); } // needed by twig, cause it tries to call a method with the property name if (property_exists($this, $name)) { $method = Get::PREFIX . ucfirst($name); return $this->{$method}(); } foreach (AccessorRegistry::getAccessors() as $prefix => $accessor) { if (strpos($name, $prefix) === 0) { $property = lcfirst(substr($name, strlen($prefix))); if (isset($this->__props[$property])) { $prop = $this->__props[$property]; if ($prop->hasMethod($prefix)) { return $accessor->callback(new CallbackBag($prop, $this, $this->{$property}, $arguments)); } } } } throw new \Exception('Call to undefined method ' . __CLASS__ . '::' . $name . '()'); }
public function testRegistry() { $accessors = AccessorRegistry::getAccessors(); $this->assertEquals(array(Add::PREFIX, Get::PREFIX, Is::PREFIX, Remove::PREFIX, Set::PREFIX), array_keys($accessors)); }