Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
| 1 | <?php |
||
| 19 | abstract class AbstractRoute extends AbstractConfig implements RouteInterface |
||
| 20 | { |
||
| 21 | /** |
||
| 22 | * @var string |
||
| 23 | */ |
||
| 24 | private $name; |
||
| 25 | |||
| 26 | /** |
||
| 27 | * @var string |
||
| 28 | */ |
||
| 29 | private $path; |
||
| 30 | |||
| 31 | /** |
||
| 32 | * @return bool |
||
| 33 | */ |
||
| 34 | public function hasName() |
||
| 38 | |||
| 39 | /** |
||
| 40 | * @return string |
||
| 41 | */ |
||
| 42 | public function getName() |
||
| 46 | |||
| 47 | /** |
||
| 48 | * {@inheritdoc} |
||
| 49 | */ |
||
| 50 | public function setName($name) |
||
| 55 | |||
| 56 | /** |
||
| 57 | * @return bool |
||
| 58 | */ |
||
| 59 | protected function hasPath() |
||
| 63 | |||
| 64 | /** |
||
| 65 | * @return string |
||
| 66 | */ |
||
| 67 | protected function getPath() |
||
| 71 | |||
| 72 | /** |
||
| 73 | * {@inheritdoc} |
||
| 74 | */ |
||
| 75 | public function setPath($path) |
||
| 80 | |||
| 81 | /** |
||
| 82 | * @param string $route |
||
| 83 | * @return $this |
||
| 84 | */ |
||
| 85 | protected function setRouteOption($route) |
||
| 90 | |||
| 91 | /** |
||
| 92 | * @return string |
||
| 93 | */ |
||
| 94 | public function getType() |
||
| 98 | |||
| 99 | /** |
||
| 100 | * {@inheritdoc} |
||
| 101 | */ |
||
| 102 | public function setType($type = self::LITERAL) |
||
| 107 | |||
| 108 | /** |
||
| 109 | * {@inheritdoc} |
||
| 110 | */ |
||
| 111 | public function setMayTerminate($mayTerminate = true) |
||
| 116 | |||
| 117 | /** |
||
| 118 | * @return array |
||
| 119 | */ |
||
| 120 | protected function getDefaults() |
||
| 124 | |||
| 125 | /** |
||
| 126 | * {@inheritdoc} |
||
| 127 | */ |
||
| 128 | View Code Duplication | public function setDefaults(array $defaults) |
|
| 136 | |||
| 137 | /** |
||
| 138 | * {@inheritdoc} |
||
| 139 | */ |
||
| 140 | public function setChild(array $routes) |
||
| 147 | |||
| 148 | /** |
||
| 149 | * {@inheritdoc} |
||
| 150 | */ |
||
| 151 | public function chain(array $routes) |
||
| 158 | |||
| 159 | /** |
||
| 160 | * @param array $handlers |
||
| 161 | * @return $this |
||
| 162 | */ |
||
| 163 | View Code Duplication | protected function setHandlers(array $handlers) |
|
| 171 | |||
| 172 | /** |
||
| 173 | * @param string $section |
||
| 174 | * @param self $route |
||
| 175 | * @return $this |
||
| 176 | */ |
||
| 177 | protected function appendRoute($section, self $route) |
||
| 192 | |||
| 193 | /** |
||
| 194 | * @param RouteInterface $route |
||
| 195 | * @return $this |
||
| 196 | */ |
||
| 197 | protected function appendChildRoute(RouteInterface $route) |
||
| 206 | } |
||
| 207 |
An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.
If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.