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 BuildR\TestTools\Asserts; |
||
17 | class IsConstantValueEqualsConstraint extends \PHPUnit_Framework_Constraint { |
||
18 | |||
19 | |||
20 | |||
21 | /** |
||
22 | * @type mixed |
||
23 | */ |
||
24 | protected $value; |
||
25 | |||
26 | /** |
||
27 | * IsConstantValueEqualsConstraint constructor |
||
28 | * |
||
29 | * @param $value mixed |
||
30 | */ |
||
31 | 6 | public function __construct($value) { |
|
32 | 6 | parent::__construct(); |
|
33 | |||
34 | 6 | $this->value = $value; |
|
35 | 6 | } |
|
36 | |||
37 | /** |
||
38 | * {@inheritDoc} |
||
39 | */ |
||
40 | 6 | View Code Duplication | protected function matches($other) { |
57 | |||
58 | /** |
||
59 | * {@inheritDoc} |
||
60 | */ |
||
61 | 2 | public function toString() { |
|
64 | |||
65 | } |
||
66 |