| @@ 118-141 (lines=24) @@ | ||
| 115 | return $this; |
|
| 116 | } |
|
| 117 | ||
| 118 | public function addGetObjectFqcnMethod() |
|
| 119 | { |
|
| 120 | if ($this->builder->hasPublicMethod('getObjectFqcn', false)) { |
|
| 121 | throw new LogicException(sprintf('Method "getObjectFqcn()" is already defined in "%s".', $this->builder->getName())); |
|
| 122 | } |
|
| 123 | ||
| 124 | $method = $this->factory->method('getObjectFqcn') |
|
| 125 | ->makeProtected() |
|
| 126 | ->addStmts($this->parser->parse(sprintf('<?php return %s::class;', $this->subject->getName()))) |
|
| 127 | ->setDocComment( |
|
| 128 | ' |
|
| 129 | /** |
|
| 130 | * {@inheritdoc} |
|
| 131 | */' |
|
| 132 | ); |
|
| 133 | ||
| 134 | if ($this->withReturnTypeDeclaration) { |
|
| 135 | $method->setReturnType('string'); |
|
| 136 | } |
|
| 137 | ||
| 138 | $this->appendMethod($method->getNode()); |
|
| 139 | ||
| 140 | return $this; |
|
| 141 | } |
|
| 142 | ||
| 143 | public function addConfigureParametersMethod() |
|
| 144 | { |
|
| @@ 143-168 (lines=26) @@ | ||
| 140 | return $this; |
|
| 141 | } |
|
| 142 | ||
| 143 | public function addConfigureParametersMethod() |
|
| 144 | { |
|
| 145 | if ($this->builder->hasPublicMethod('configureParameters', false)) { |
|
| 146 | throw new LogicException(sprintf('Method "configureParameters()" is already defined in "%s".', $this->builder->getName())); |
|
| 147 | } |
|
| 148 | ||
| 149 | $method = $this->factory->method('configureParameters') |
|
| 150 | ->makeProtected() |
|
| 151 | ->addStmts($this->parser->parse("<?php \$defaults = parent::configureParameters();\n// Modify default values here\nreturn \$defaults;")) |
|
| 152 | ->setDocComment( |
|
| 153 | ' |
|
| 154 | /** |
|
| 155 | * You can override default building parameter values here |
|
| 156 | * |
|
| 157 | * {@inheritdoc} |
|
| 158 | */' |
|
| 159 | ); |
|
| 160 | ||
| 161 | if ($this->withReturnTypeDeclaration) { |
|
| 162 | $method->setReturnType('array'); |
|
| 163 | } |
|
| 164 | ||
| 165 | $this->appendMethod($method->getNode()); |
|
| 166 | ||
| 167 | return $this; |
|
| 168 | } |
|
| 169 | ||
| 170 | public function addGetter($name, ParameterMetadata $parameter) |
|
| 171 | { |
|