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 |
||
| 30 | class Certificates implements ISettings { |
||
| 31 | |||
| 32 | /** @var IConfig */ |
||
| 33 | protected $config; |
||
| 34 | /** @var ICertificateManager */ |
||
| 35 | protected $certificateManager; |
||
| 36 | /** @var IURLGenerator */ |
||
| 37 | protected $urlGenerator; |
||
| 38 | |||
| 39 | public function __construct(IConfig $config, |
||
| 40 | IURLGenerator $urlGenerator, |
||
| 41 | ICertificateManager $certificateManager) { |
||
| 42 | $this->config = $config; |
||
| 43 | $this->urlGenerator = $urlGenerator; |
||
| 44 | $this->certificateManager = $certificateManager; |
||
| 45 | } |
||
| 46 | |||
| 47 | public function getPriority() { |
||
| 50 | |||
| 51 | View Code Duplication | public function getPanel() { |
|
| 63 | |||
| 64 | public function getSectionID() { |
||
| 67 | |||
| 68 | } |
||
| 69 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: