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 |
||
11 | class Image extends OperatorResource implements Listable, Retrievable, Deletable |
||
12 | { |
||
13 | public $status; |
||
14 | public $username; |
||
15 | public $updated; |
||
16 | public $OSEXTIMGSIZEsize; |
||
17 | public $created; |
||
18 | public $tags; |
||
19 | public $minDisk; |
||
20 | public $name; |
||
21 | public $progress; |
||
22 | public $minRam; |
||
23 | public $metadata; |
||
24 | public $id; |
||
25 | public $description; |
||
26 | |||
27 | protected $resourceKey = 'image'; |
||
28 | protected $resourcesKey = 'images'; |
||
29 | |||
30 | protected $aliases = [ |
||
31 | 'OS-EXT-IMG-SIZE:size' => 'OSEXTIMGSIZEsize', |
||
32 | ]; |
||
33 | |||
34 | public function retrieve() |
||
39 | |||
40 | public function delete() |
||
44 | |||
45 | public function update() |
||
50 | |||
51 | public function register(array $userOptions) |
||
57 | |||
58 | public function unregister() |
||
62 | |||
63 | View Code Duplication | public function addTags(array $userOptions) |
|
70 | |||
71 | View Code Duplication | public function removeTags(array $userOptions) |
|
78 | } |
||
79 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.