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 |
||
| 14 | class GenerationBench |
||
| 15 | { |
||
| 16 | /** |
||
| 17 | * @var Router |
||
| 18 | */ |
||
| 19 | protected $router; |
||
| 20 | |||
| 21 | public function benchAssembleStaticNip() |
||
| 22 | { |
||
| 23 | $this->router->assemble( |
||
| 24 | 'index.999', |
||
| 25 | ['controller' => 'posts', 'action' => 'create', 'title' => 'test'] |
||
| 26 | ); |
||
| 27 | } |
||
| 28 | |||
| 29 | public function benchAssembleStandardNip() |
||
| 30 | { |
||
| 31 | $this->router->assemble( |
||
| 32 | 'index.standard999', |
||
| 33 | ['controller' => 'posts', 'action' => 'create', 'title' => 'test'] |
||
| 34 | ); |
||
| 35 | } |
||
| 36 | |||
| 37 | public function benchAssembleStaticSymfony() |
||
| 38 | { |
||
| 39 | $this->router->generate( |
||
| 40 | 'index.999', |
||
| 41 | ['controller' => 'posts', 'action' => 'create', 'title' => 'test'] |
||
| 42 | ); |
||
| 43 | } |
||
| 44 | |||
| 45 | public function benchAssembleDynamicSymfony() |
||
| 46 | { |
||
| 47 | $this->router->generate( |
||
| 48 | 'index.standard999', |
||
| 49 | ['controller' => 'posts', 'action' => 'create', 'title' => 'test'] |
||
| 50 | ); |
||
| 51 | } |
||
| 52 | |||
| 53 | public function init() |
||
| 71 | } |
||
| 72 | } |
||
| 73 | } |
||
| 74 |