1 | <?php |
||
24 | trait MonitorTrait |
||
25 | { |
||
26 | use EventEmitterTrait; |
||
27 | |||
28 | /** |
||
29 | * The monitor's WAMP client session. |
||
30 | * |
||
31 | * @var ClientSession |
||
32 | */ |
||
33 | protected $session; |
||
34 | |||
35 | /** |
||
36 | * if the monitor is running. |
||
37 | * |
||
38 | * @var bool |
||
39 | */ |
||
40 | protected $isRunning = false; |
||
41 | |||
42 | /** |
||
43 | * @var SubscriptionCollection |
||
44 | */ |
||
45 | protected $subscriptionCollection; |
||
46 | |||
47 | /** |
||
48 | * @var string |
||
49 | */ |
||
50 | protected $initialCallProcedure; |
||
51 | |||
52 | /** |
||
53 | * @var callable |
||
54 | */ |
||
55 | protected $initialCallCallback; |
||
56 | |||
57 | /** |
||
58 | * @var bool |
||
59 | */ |
||
60 | protected $initialCallDone = false; |
||
61 | |||
62 | /** |
||
63 | * @param ClientSession $session |
||
64 | */ |
||
65 | protected function setClientSession(ClientSession $session) |
||
69 | |||
70 | /** |
||
71 | * Start the monitor. |
||
72 | * |
||
73 | * @return bool |
||
74 | */ |
||
75 | public function start() |
||
82 | |||
83 | /** |
||
84 | * Stop the monitor. |
||
85 | * Returns boolean if the monitor could be started. |
||
86 | * |
||
87 | * @return bool |
||
88 | */ |
||
89 | public function stop() |
||
102 | |||
103 | protected function getList() |
||
107 | |||
108 | /** |
||
109 | * Get the monitor's WAMP client session. |
||
110 | * |
||
111 | * @return ClientSession |
||
112 | */ |
||
113 | public function getServerSession() |
||
117 | |||
118 | /** |
||
119 | * Get the monitor's running state. |
||
120 | * |
||
121 | * @return bool |
||
122 | */ |
||
123 | public function isRunning() |
||
127 | |||
128 | /** |
||
129 | * @return \Tidal\WampWatch\Subscription\Collection |
||
130 | */ |
||
131 | protected function getSubscriptionCollection() |
||
137 | |||
138 | protected function setInitialCall($pocedure, callable $callback) |
||
143 | |||
144 | /** |
||
145 | * @return \React\Promise\PromiseInterface |
||
146 | */ |
||
147 | protected function callInitialProcedure() |
||
163 | |||
164 | /** |
||
165 | * Checks if all necessary subscriptions and calls have been responded to. |
||
166 | */ |
||
167 | protected function checkStarted() |
||
176 | } |
||
177 |
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.