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 |
||
| 21 | View Code Duplication | abstract class AbstractGetService implements ServiceInterface |
|
| 22 | { |
||
| 23 | /** |
||
| 24 | * @var RepositoryInterface $repository |
||
| 25 | */ |
||
| 26 | protected $repository; |
||
| 27 | |||
| 28 | /** |
||
| 29 | * @var string $uuid |
||
| 30 | */ |
||
| 31 | protected $uuid; |
||
| 32 | |||
| 33 | /** |
||
| 34 | * @var LoggerInterface $logger |
||
| 35 | */ |
||
| 36 | protected $logger; |
||
| 37 | |||
| 38 | /** |
||
| 39 | * AbstractGetService constructor. |
||
| 40 | * @param RepositoryInterface $repository |
||
| 41 | * @param string $uuid |
||
| 42 | * @param LoggerInterface $logger |
||
| 43 | */ |
||
| 44 | 12 | public function __construct(RepositoryInterface $repository, string $uuid, LoggerInterface $logger) |
|
| 50 | |||
| 51 | /** |
||
| 52 | * @return stdClass|null |
||
| 53 | */ |
||
| 54 | 12 | public function run() |
|
| 64 | } |
||
| 65 |