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 |
||
| 7 | class Kavenegar extends Driver |
||
| 8 | { |
||
| 9 | /** |
||
| 10 | * Kavenegar Settings. |
||
| 11 | * |
||
| 12 | * @var null|object |
||
| 13 | */ |
||
| 14 | protected $settings = null; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * Kavenegar Client. |
||
| 18 | * |
||
| 19 | * @var null|Client |
||
| 20 | */ |
||
| 21 | protected $client = null; |
||
| 22 | |||
| 23 | /** |
||
| 24 | * Construct the class with the relevant settings. |
||
| 25 | * |
||
| 26 | * SendSmsInterface constructor. |
||
| 27 | * @param $settings object |
||
| 28 | */ |
||
| 29 | public function __construct($settings) |
||
| 34 | |||
| 35 | /** |
||
| 36 | * Send text message and return response. |
||
| 37 | * |
||
| 38 | * @return object |
||
| 39 | */ |
||
| 40 | public function send() |
||
| 61 | |||
| 62 | /** |
||
| 63 | * Get the Kavenegar Response. |
||
| 64 | * |
||
| 65 | * @param $sms |
||
| 66 | * @return object |
||
| 67 | */ |
||
| 68 | protected function getSmsResponse($sms) |
||
| 82 | } |
||
| 83 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..