1 | <?php |
||
4 | trait ObjectTools |
||
5 | { |
||
6 | /** |
||
7 | * Check basic rule |
||
8 | * |
||
9 | * @param string $path |
||
10 | * @param array $paths |
||
11 | * @return bool |
||
12 | */ |
||
13 | public function checkPath($path, $paths) |
||
30 | |||
31 | /** |
||
32 | * Generate directive/rule pair |
||
33 | * |
||
34 | * @param string $line |
||
35 | * @param array $whiteList |
||
36 | * @return array|false |
||
37 | */ |
||
38 | protected function generateRulePair($line, $whiteList) |
||
57 | |||
58 | /** |
||
59 | * Get path |
||
60 | * |
||
61 | * @param string $url |
||
62 | * @return string |
||
63 | * @throws Exceptions\ClientException |
||
64 | */ |
||
65 | protected function getPath($url) |
||
77 | } |
||
78 |
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.