/** * @param PropertyFactory $property * * @return ClassFactory */ public function addHasser(PropertyFactory $property) { $hasser = new MethodFactory('has' . ucfirst($property->getName())); $hasser->addArgument('key'); $hasser->setBody('return isset($this->' . $property->getName() . '[$key]);'); $this->addMethod($hasser); return $this; }
public function doneAndReset() { $ret = $this->done(); $this->reset(); return $ret; } public function reset() { $this->options_ = []; return $this; } public function __call($name, $argv) { switch ($name) { case 'default': if (count($argv) !== 1) { throw new \BadMethodCallException(sprintf('Method "%s::%s()" requires a single argument, %d arguments passed', __CLASS__, $name, count($argv))); } return $this->defVal($argv[0]); default: throw new \BadMethodCallException(sprintf('Method "%s::%s()" does not exist', __CLASS__, $name)); } } private function defVal($value) { $this->options_['default'] = $value; return $this; } } $c = new PropertyFactory(); $c->default('dsf');