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 namespace Anomaly\Streams\Platform\Ui\Form; |
||
| 17 | class FormCriteria |
||
| 18 | { |
||
| 19 | |||
| 20 | use FiresCallbacks; |
||
| 21 | |||
| 22 | /** |
||
| 23 | * The cache repository. |
||
| 24 | * |
||
| 25 | * @var Repository |
||
| 26 | */ |
||
| 27 | protected $cache; |
||
| 28 | |||
| 29 | /** |
||
| 30 | * The form builder. |
||
| 31 | * |
||
| 32 | * @var FormBuilder |
||
| 33 | */ |
||
| 34 | protected $builder; |
||
| 35 | |||
| 36 | /** |
||
| 37 | * The request object. |
||
| 38 | * |
||
| 39 | * @var Request |
||
| 40 | */ |
||
| 41 | protected $request; |
||
| 42 | |||
| 43 | /** |
||
| 44 | * The hydrator utility. |
||
| 45 | * |
||
| 46 | * @var Hydrator |
||
| 47 | */ |
||
| 48 | protected $hydrator; |
||
| 49 | |||
| 50 | /** |
||
| 51 | * The parameters. |
||
| 52 | * |
||
| 53 | * @var array |
||
| 54 | */ |
||
| 55 | protected $parameters = []; |
||
| 56 | |||
| 57 | /** |
||
| 58 | * Create a new FormCriteria instance. |
||
| 59 | * |
||
| 60 | * @param Repository $cache |
||
| 61 | * @param Request $request |
||
| 62 | * @param Hydrator $hydrator |
||
| 63 | * @param FormBuilder $builder |
||
| 64 | * @param array $parameters |
||
| 65 | */ |
||
| 66 | public function __construct( |
||
| 81 | |||
| 82 | /** |
||
| 83 | * Get the form. |
||
| 84 | * |
||
| 85 | * @return FormPresenter |
||
| 86 | */ |
||
| 87 | public function get() |
||
| 115 | |||
| 116 | /** |
||
| 117 | * Return the hydrated builder. |
||
| 118 | * |
||
| 119 | * @return FormBuilder |
||
| 120 | */ |
||
| 121 | public function builder() |
||
| 127 | |||
| 128 | /** |
||
| 129 | * Get the builder. |
||
| 130 | * |
||
| 131 | * @return FormBuilder |
||
| 132 | */ |
||
| 133 | public function getBuilder() |
||
| 137 | |||
| 138 | /** |
||
| 139 | * Set the form builder. |
||
| 140 | * |
||
| 141 | * @param FormBuilder $builder |
||
| 142 | * @return $this |
||
| 143 | */ |
||
| 144 | protected function setBuilder(FormBuilder $builder) |
||
| 159 | |||
| 160 | /** |
||
| 161 | * Route through __get |
||
| 162 | * |
||
| 163 | * @param $name |
||
| 164 | * @return $this |
||
| 165 | */ |
||
| 166 | public function __get($name) |
||
| 170 | |||
| 171 | /** |
||
| 172 | * @param $name |
||
| 173 | * @param $arguments |
||
| 174 | * @return $this |
||
| 175 | */ |
||
| 176 | public function __call($name, $arguments) |
||
| 214 | |||
| 215 | /** |
||
| 216 | * Return the form. |
||
| 217 | * |
||
| 218 | * @return string |
||
| 219 | */ |
||
| 220 | public function __toString() |
||
| 224 | } |
||
| 225 |