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 AbstractPackage extends AbstractGithubObject |
||
19 | { |
||
20 | /** |
||
21 | * Constructor. |
||
22 | * |
||
23 | * @param Registry $options GitHub options object. |
||
24 | * @param Http $client The HTTP client object. |
||
25 | * |
||
26 | * @since 1.0 |
||
27 | */ |
||
28 | public function __construct(Registry $options = null, Http $client = null) |
||
35 | |||
36 | /** |
||
37 | * Magic method to lazily create API objects |
||
38 | * |
||
39 | * @param string $name Name of property to retrieve |
||
40 | * |
||
41 | * @since 1.0 |
||
42 | * @throws \InvalidArgumentException |
||
43 | * |
||
44 | * @return AbstractPackage GitHub API package object. |
||
45 | */ |
||
46 | public function __get($name) |
||
67 | } |
||
68 |
When comparing two booleans, it is generally considered safer to use the strict comparison operator.