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 |
||
33 | trait MountableTrait |
||
34 | { |
||
35 | /** |
||
36 | * filesystem map |
||
37 | * |
||
38 | * @var FilesystemInterface[] |
||
39 | * @access protected |
||
40 | */ |
||
41 | protected $filesystems = []; |
||
42 | |||
43 | /** |
||
44 | * {@inheritDoc} |
||
45 | */ |
||
46 | View Code Duplication | public function mount( |
|
64 | |||
65 | /** |
||
66 | * {@inheritDoc} |
||
67 | */ |
||
68 | View Code Duplication | public function umount(/*# string */ $mountPoint)/*# : bool */ |
|
86 | |||
87 | /** |
||
88 | * Clean path to standard mount point |
||
89 | * |
||
90 | * @param string $path |
||
91 | * @return string |
||
92 | * @access protected |
||
93 | */ |
||
94 | protected function cleanMountPoint(/*# string */ $path)/*# : string */ |
||
98 | |||
99 | /** |
||
100 | * Get the filesystem at mount point |
||
101 | * |
||
102 | * @param string $mountPoint |
||
103 | * @return FilesystemInterface |
||
104 | * @access protected |
||
105 | */ |
||
106 | protected function getFilesystemAt( |
||
111 | |||
112 | /** |
||
113 | * Find mount point of the path |
||
114 | * |
||
115 | * @param string $path |
||
116 | * @return string |
||
117 | * @access protected |
||
118 | */ |
||
119 | protected function getMountPoint(/*# string */ $path)/*# : string */ |
||
129 | } |
||
130 |