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 |
||
| 20 | class ProphecyMockingStrategy extends AbstractMockingStrategy |
||
| 21 | { |
||
| 22 | const CLASS_NAME = Prophet::class; |
||
| 23 | const PACKAGE_NAME = 'phpspec/prophecy'; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * @var Prophet |
||
| 27 | */ |
||
| 28 | private $prophet; |
||
| 29 | |||
| 30 | /** |
||
| 31 | * PHPUnitMockingStrategy constructor. |
||
| 32 | * |
||
| 33 | * @throws MissingDependencyException |
||
| 34 | */ |
||
| 35 | 2 | public function __construct() |
|
| 42 | |||
| 43 | /** |
||
| 44 | * @param string $fqcn |
||
| 45 | * @return ObjectProphecy |
||
| 46 | */ |
||
| 47 | 24 | protected function doBuild(string $fqcn) |
|
| 51 | |||
| 52 | /** |
||
| 53 | * @param ObjectProphecy $mock |
||
| 54 | * @param Stub $stub |
||
| 55 | * @return void |
||
| 56 | */ |
||
| 57 | 23 | View Code Duplication | protected function doDecorate($mock, Stub $stub) |
| 68 | |||
| 69 | /** |
||
| 70 | * @param ObjectProphecy $mock |
||
| 71 | * @return mixed |
||
| 72 | * |
||
| 73 | * @throws MockNotCreatedException |
||
| 74 | */ |
||
| 75 | 13 | protected function doGet($mock) |
|
| 88 | |||
| 89 | public function call($object, string $name, array $arguments) |
||
| 93 | } |
||
| 94 |