Total Complexity | 6 |
Total Lines | 62 |
Duplicated Lines | 19.35 % |
Changes | 0 |
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 | trait LazyArrayAccess |
||
12 | { |
||
13 | /** |
||
14 | * Determines if given offset exists in current collection. |
||
15 | * |
||
16 | * @param mixed $offset |
||
17 | * |
||
18 | * @return bool |
||
19 | */ |
||
20 | public function offsetExists($offset) |
||
21 | { |
||
22 | $this->checkLazyLoad(); |
||
|
|||
23 | |||
24 | return isset($this->items[$offset]); |
||
25 | } |
||
26 | |||
27 | /** |
||
28 | * Puts value to given offset or appends it to current collection. |
||
29 | * |
||
30 | * @param mixed $offset |
||
31 | * @param mixed $value |
||
32 | */ |
||
33 | View Code Duplication | public function offsetSet($offset, $value) |
|
44 | } |
||
45 | |||
46 | /** |
||
47 | * Retrieves given offset from current collection. |
||
48 | * Returns NULL if no value found. |
||
49 | * |
||
50 | * @param mixed $offset |
||
51 | * |
||
52 | * @return mixed|null |
||
53 | */ |
||
54 | public function offsetGet($offset) |
||
59 | } |
||
60 | |||
61 | /** |
||
62 | * Drops given offset from current collection. |
||
63 | * |
||
64 | * @param mixed $offset |
||
65 | */ |
||
66 | public function offsetUnset($offset) |
||
73 | } |
||
74 | } |
||
75 |