1 | <?php |
||
24 | trait HasProceduresTrait |
||
25 | { |
||
26 | protected static $proceduresPropertyName = 'procedures'; |
||
27 | |||
28 | /** |
||
29 | * @var ObjectCollectionInterface |
||
30 | */ |
||
31 | private $procedures; |
||
32 | |||
33 | public function addProcedure(Contract\ProcedureInterface $procedure) |
||
37 | |||
38 | /** |
||
39 | * @return ObjectCollectionInterface |
||
40 | */ |
||
41 | private function getProcedures() |
||
45 | |||
46 | /** |
||
47 | * @param string $name |
||
48 | * |
||
49 | * @return ObjectCollectionInterface |
||
50 | */ |
||
51 | abstract protected function getCollection($name); |
||
52 | |||
53 | public function hasProcedure($uri) |
||
57 | |||
58 | /** |
||
59 | * @param string $uri |
||
60 | * |
||
61 | * @return Contract\ProcedureInterface |
||
62 | */ |
||
63 | public function getProcedure($uri) |
||
67 | |||
68 | /** |
||
69 | * @param string $uri |
||
70 | */ |
||
71 | public function removeProcedure($uri) |
||
75 | |||
76 | /** |
||
77 | * @return \Generator |
||
78 | */ |
||
79 | public function listProcedures() |
||
85 | |||
86 | /** |
||
87 | * @param ObjectCollectionInterface $procedures |
||
88 | */ |
||
89 | private function setProcedures(ObjectCollectionInterface $procedures) |
||
94 | } |
||
95 |
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.