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 Installer extends \Jitamin\Foundation\Base |
||
21 | { |
||
22 | /** |
||
23 | * Return true if Jitamin is configured to install plugins. |
||
24 | * |
||
25 | * @static |
||
26 | * |
||
27 | * @return bool |
||
28 | */ |
||
29 | public static function isConfigured() |
||
33 | |||
34 | /** |
||
35 | * Install a plugin. |
||
36 | * |
||
37 | * @param string $archiveUrl |
||
38 | * |
||
39 | * @throws PluginInstallerException |
||
40 | */ |
||
41 | public function install($archiveUrl) |
||
53 | |||
54 | /** |
||
55 | * Uninstall a plugin. |
||
56 | * |
||
57 | * @param string $pluginId |
||
58 | * |
||
59 | * @throws PluginInstallerException |
||
60 | */ |
||
61 | public function uninstall($pluginId) |
||
75 | |||
76 | /** |
||
77 | * Update a plugin. |
||
78 | * |
||
79 | * @param string $archiveUrl |
||
80 | * |
||
81 | * @throws PluginInstallerException |
||
82 | */ |
||
83 | public function update($archiveUrl) |
||
98 | |||
99 | /** |
||
100 | * Download archive from URL. |
||
101 | * |
||
102 | * @param string $archiveUrl |
||
103 | * |
||
104 | * @throws PluginInstallerException |
||
105 | * |
||
106 | * @return ZipArchive |
||
107 | */ |
||
108 | protected function downloadPluginArchive($archiveUrl) |
||
140 | |||
141 | /** |
||
142 | * Remove archive file. |
||
143 | * |
||
144 | * @param ZipArchive $zip |
||
145 | */ |
||
146 | protected function cleanupArchive(ZipArchive $zip) |
||
151 | } |
||
152 |
Since your code implements the magic getter
_get
, this function will be called for any read access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.If the property has read access only, you can use the @property-read annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.