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 |
||
14 | class Apcu implements ICache |
||
15 | { |
||
16 | use injector; |
||
17 | |||
18 | /** |
||
19 | * @var Container キャッシュ依存コンテナ |
||
20 | */ |
||
21 | private $cacheContainer; |
||
22 | |||
23 | /** |
||
24 | * {@inheritdoc} |
||
25 | */ |
||
26 | public function __construct(Container $cacheContainer) |
||
30 | |||
31 | /** |
||
32 | * {@inheritdoc} |
||
33 | */ |
||
34 | public function add($key, $value, $ttl = 0, $overrite = false): bool |
||
46 | |||
47 | /** |
||
48 | * {@inheritdoc} |
||
49 | */ |
||
50 | public function get($key) |
||
67 | |||
68 | /** |
||
69 | * {@inheritdoc} |
||
70 | */ |
||
71 | View Code Duplication | public function delete($key): bool |
|
86 | |||
87 | /** |
||
88 | * {@inheritdoc} |
||
89 | */ |
||
90 | public function clear(): bool |
||
109 | |||
110 | /** |
||
111 | * キャッシュライブラリが使用可能か検査する |
||
112 | * @return bool 使用可能でtrue |
||
113 | */ |
||
114 | private function isAvailableCacheLibrary(): bool |
||
124 | } |
||
125 |
Since your code implements the magic getter
_get
, this function will be called for any read access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.If the property has read access only, you can use the @property-read annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.