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 Plugin implements PluginInterface, EventSubscriberInterface |
||
| 21 | { |
||
| 22 | const PERMISSION_CODE = 0755; |
||
| 23 | const REPEAT = 5; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * @var Installer |
||
| 27 | */ |
||
| 28 | protected $installer; |
||
| 29 | |||
| 30 | /** |
||
| 31 | * @var string |
||
| 32 | */ |
||
| 33 | protected $environment; |
||
| 34 | |||
| 35 | /** |
||
| 36 | * Create instance, define constants |
||
| 37 | */ |
||
| 38 | public function __construct() |
||
| 43 | |||
| 44 | /** |
||
| 45 | * Called after the plugin is loaded |
||
| 46 | * |
||
| 47 | * It setup composer installer |
||
| 48 | * |
||
| 49 | * {@inheritDoc} |
||
| 50 | */ |
||
| 51 | public function activate(Composer $composer, IOInterface $io) |
||
| 56 | |||
| 57 | /** |
||
| 58 | * Registered events after the plugin is loaded |
||
| 59 | * |
||
| 60 | * {@inheritDoc} |
||
| 61 | */ |
||
| 62 | public static function getSubscribedEvents(): array |
||
| 86 | |||
| 87 | /** |
||
| 88 | * Hook which is called after install package |
||
| 89 | * |
||
| 90 | * It copies bluz module |
||
| 91 | */ |
||
| 92 | public function onPostPackageInstall() |
||
| 96 | |||
| 97 | /** |
||
| 98 | * Hook which is called before update package |
||
| 99 | * |
||
| 100 | * It copies bluz module |
||
| 101 | */ |
||
| 102 | public function onPrePackageUpdate() |
||
| 106 | |||
| 107 | /** |
||
| 108 | * Hook which is called after update package |
||
| 109 | * |
||
| 110 | * It copies bluz module |
||
| 111 | */ |
||
| 112 | public function onPostPackageUpdate() |
||
| 116 | |||
| 117 | /** |
||
| 118 | * Hook which is called before remove package |
||
| 119 | * |
||
| 120 | * It copies bluz module |
||
| 121 | */ |
||
| 122 | public function onPrePackageRemove() |
||
| 126 | |||
| 127 | /** |
||
| 128 | * It recursively copies the files and directories |
||
| 129 | * @return bool |
||
| 130 | */ |
||
| 131 | protected function copy() |
||
| 154 | |||
| 155 | /** |
||
| 156 | * It recursively check changes in the files |
||
| 157 | * @return bool |
||
| 158 | */ |
||
| 159 | View Code Duplication | protected function check() |
|
| 175 | |||
| 176 | /** |
||
| 177 | * It recursively removes the files and directories |
||
| 178 | * @return bool |
||
| 179 | */ |
||
| 180 | View Code Duplication | protected function remove() |
|
| 196 | } |
||
| 197 |
This class constant has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the constant will be removed from the class and what other constant to use instead.