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 |
||
35 | class FileStreamConfig { |
||
36 | |||
37 | /** @var string */ |
||
38 | private $filename; |
||
39 | |||
40 | /** @var integer */ |
||
41 | private $mode; |
||
42 | |||
43 | /** @var boolean */ |
||
44 | private $useIncludePath; |
||
45 | |||
46 | /** @var array */ |
||
47 | private $context; |
||
48 | |||
49 | /** |
||
50 | * @param string $filename |
||
51 | * @param integer $mode |
||
52 | * @param boolean $useIncludePath |
||
53 | * @param array $context |
||
54 | * @throws \InvalidArgumentException |
||
55 | */ |
||
56 | 1 | View Code Duplication | public function __construct($filename, $mode, $useIncludePath = false, array $context = array()) { |
66 | |||
67 | /** |
||
68 | * Returns the configuration file name. |
||
69 | * @return string the file name |
||
70 | */ |
||
71 | 1 | public function getFilename() { |
|
74 | |||
75 | /** |
||
76 | * Returns the file accessing mode. |
||
77 | * @return integer the file accessing mode |
||
78 | */ |
||
79 | 1 | public function getMode() { |
|
82 | |||
83 | /** |
||
84 | * Checks if the include path should also be used. |
||
85 | * @return boolean check result |
||
86 | */ |
||
87 | 1 | public function shouldUseIncludePath() { |
|
90 | |||
91 | /** |
||
92 | * Returns the file stream context options. |
||
93 | * @return array the context options |
||
94 | */ |
||
95 | 1 | public function getContext() { |
|
98 | |||
99 | } |
||
100 |