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 |
||
| 17 | class PHPUnitMockingStrategy extends AbstractMockingStrategy |
||
| 18 | { |
||
| 19 | /** |
||
| 20 | * @var MockGenerator |
||
| 21 | */ |
||
| 22 | private $generator; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * PHPUnitMockingStrategy constructor. |
||
| 26 | */ |
||
| 27 | 12 | public function __construct() |
|
| 32 | |||
| 33 | /** |
||
| 34 | * @param string $fqcn |
||
| 35 | * @return MockObject |
||
| 36 | * |
||
| 37 | * @throws MockNotCreatedException |
||
| 38 | */ |
||
| 39 | 15 | public function build(string $fqcn) |
|
| 60 | |||
| 61 | /** |
||
| 62 | * @param MockObject $mock |
||
| 63 | * @param StubSet $stubs |
||
| 64 | * @return void |
||
| 65 | * |
||
| 66 | * @throws InvalidArgumentException |
||
| 67 | */ |
||
| 68 | 12 | View Code Duplication | public function decorate($mock, StubSet $stubs) |
| 82 | |||
| 83 | /** |
||
| 84 | * @param MockObject $mock |
||
| 85 | * @return MockObject |
||
| 86 | * |
||
| 87 | * @throws InvalidArgumentException |
||
| 88 | */ |
||
| 89 | 13 | public function get($mock) |
|
| 95 | } |
||
| 96 |