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 |
||
18 | abstract class SearchDbConnected |
||
19 | { |
||
20 | /** |
||
21 | * @var resource |
||
22 | */ |
||
23 | protected $searchDbHandle; |
||
24 | |||
25 | /** |
||
26 | * @var \library\storage\JsonStorage |
||
27 | */ |
||
28 | protected $storage; |
||
29 | |||
30 | /** |
||
31 | * Indexer constructor. |
||
32 | * |
||
33 | * @param \library\storage\JsonStorage $storage |
||
34 | */ |
||
35 | public function __construct(JsonStorage $storage) |
||
41 | |||
42 | protected function initializeDb() |
||
48 | |||
49 | protected function configureDatabase() |
||
56 | |||
57 | protected function isDatabaseConfigured() |
||
64 | |||
65 | View Code Duplication | protected function getSearchDbHandle() |
|
73 | } |
An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.
If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.