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 |
||
11 | View Code Duplication | class TranslatorFacade |
|
12 | { |
||
13 | /** @var self|null */ |
||
14 | private static $instance = null; |
||
15 | |||
16 | /** @var ContainerInterface */ |
||
17 | private static $Container; |
||
18 | |||
19 | /** @var TranslatorInterface */ |
||
20 | private static $Translator; |
||
21 | |||
22 | /** |
||
23 | * @param ContainerInterface $container |
||
24 | */ |
||
25 | private function __construct(ContainerInterface $container, TranslatorInterface $Translator) |
||
30 | |||
31 | /** |
||
32 | * @param ContainerInterface $container |
||
33 | * |
||
34 | * @return null|TranslatorFacade |
||
35 | */ |
||
36 | public static function init(ContainerInterface $container, TranslatorInterface $Translator) |
||
44 | |||
45 | /** |
||
46 | * @return TranslatorInterface |
||
47 | * @throws \Exception |
||
48 | */ |
||
49 | public static function create() |
||
57 | } |
||
58 |