1 | <?php |
||
12 | trait HasStoresTrait |
||
13 | { |
||
14 | /** |
||
15 | * The array of resolved cache stores. |
||
16 | * |
||
17 | * @var array |
||
18 | */ |
||
19 | protected $stores = []; |
||
20 | |||
21 | /** |
||
22 | * Get a cache store instance by name. |
||
23 | * |
||
24 | * @param string|null $name |
||
25 | * @return Repository |
||
26 | */ |
||
27 | 3 | public function store($name = null) |
|
32 | |||
33 | /** |
||
34 | * Get the default cache driver name. |
||
35 | * |
||
36 | * @return string |
||
37 | */ |
||
38 | 2 | public function getDefaultStore() |
|
42 | |||
43 | /** |
||
44 | * Attempt to get the store from the local cache. |
||
45 | * |
||
46 | * @param string $name |
||
47 | * @return Repository |
||
48 | */ |
||
49 | 2 | protected function getStore($name) |
|
54 | |||
55 | /** |
||
56 | * @param $name |
||
57 | * @return Repository |
||
58 | */ |
||
59 | 2 | protected function resolve($name) |
|
75 | |||
76 | /** |
||
77 | * @param $driver |
||
78 | * @return Repository |
||
79 | */ |
||
80 | 2 | protected function repository($driver) |
|
84 | } |
||
85 |
This check looks for methods that are used by a trait but not required by it.
To illustrate, let’s look at the following code example
The trait
Idable
provides a methodequalsId
that in turn relies on the methodgetId()
. If this method does not exist on a class mixing in this trait, the method will fail.Adding the
getId()
as an abstract method to the trait will make sure it is available.