Пример #1
0
 public function writeMethod(Method $method, CodeWriter $writer)
 {
     if ($method->getNumberOfRequiredParameters() !== 1) {
         throw new \LogicException("@Bind only for setter method");
     }
     $name = null;
     if (stripos($method->name, "set") === 0) {
         $name = lcfirst(substr($method->name, 3));
     }
     $name = $method->getAnnotation("Spot\\Domain\\Bind")->value ?: $name;
     if (empty($name)) {
         throw new \LogicException("Invalid binding name in {$method->class}::{$method->name}()");
     }
     $writer->write('isset($b["', $name, '"]) && ');
     $writer->write('$i->', $method->name, '(');
     ($class = $method->getParameters()[0]->getClass()) ? $this->writeTypedBinding($class, $name, $writer) : $this->writeBinding($name, $writer);
     $writer->writeln(');');
 }