1 | <?php |
||
35 | class Jarvis extends Container implements BroadcasterInterface |
||
36 | { |
||
37 | const DEFAULT_DEBUG = false; |
||
38 | const CONTAINER_PROVIDER_FQCN = ContainerProvider::class; |
||
39 | |||
40 | private $receivers = []; |
||
41 | private $permanentEvents = []; |
||
42 | private $computedReceivers = []; |
||
43 | private $masterEmitter = false; |
||
44 | private $masterSet = false; |
||
45 | |||
46 | /** |
||
47 | * Creates an instance of Jarvis. It can take settings as first argument. |
||
48 | * List of accepted options: |
||
49 | * - container_provider (type: string|array): fqcn of your container provider |
||
50 | * |
||
51 | * @param array $settings Your own settings to modify Jarvis behavior |
||
52 | */ |
||
53 | public function __construct(array $settings = []) |
||
75 | |||
76 | public function __destruct() |
||
80 | |||
81 | /** |
||
82 | * This method is an another way to get a locked value. |
||
83 | * |
||
84 | * Example: $this['foo'] is equal to $this->foo, but it ONLY works for locked values. |
||
85 | * |
||
86 | * @param string $key The key of the locked value |
||
87 | * @return mixed |
||
88 | * @throws \InvalidArgumentException if the requested key is not associated to a locked service |
||
89 | */ |
||
90 | public function __get(string $key) |
||
100 | |||
101 | /** |
||
102 | * Sets new attributes to Jarvis. Note that this method is reserved to Jarvis itself only. |
||
103 | * |
||
104 | * @param string $key The key name of the new attribute |
||
105 | * @param mixed $value The value to associate to provided key |
||
106 | * @throws \LogicException if this method is not called by Jarvis itself |
||
107 | */ |
||
108 | public function __set(string $key, $value) |
||
116 | |||
117 | /** |
||
118 | * @param Request|null $request |
||
119 | * @return Response |
||
120 | */ |
||
121 | public function run(Request $request = null): Response |
||
122 | { |
||
123 | $request = $request ?? $this->request; |
||
124 | $response = null; |
||
125 | |||
126 | try { |
||
127 | $this->masterBroadcast(BroadcasterInterface::RUN_EVENT, $runEvent = new RunEvent($request)); |
||
128 | |||
129 | if ($response = $runEvent->response()) { |
||
130 | return $response; |
||
131 | } |
||
132 | |||
133 | $routeInfo = $this->router->match($request->getMethod(), $request->getPathInfo()); |
||
134 | if (Dispatcher::FOUND === $routeInfo[0]) { |
||
135 | $callback = $this->callbackResolver->resolve($routeInfo[1]); |
||
136 | |||
137 | $event = new ControllerEvent($callback, $routeInfo[2]); |
||
138 | $this->masterBroadcast(BroadcasterInterface::CONTROLLER_EVENT, $event); |
||
139 | |||
140 | $response = call_user_func_array($event->callback(), $event->arguments()); |
||
141 | |||
142 | if (is_scalar($response)) { |
||
143 | $response = new Response((string) $response); |
||
144 | } |
||
145 | } else { |
||
146 | $response = new Response(null, Dispatcher::NOT_FOUND === $routeInfo[0] |
||
147 | ? Response::HTTP_NOT_FOUND |
||
148 | : Response::HTTP_METHOD_NOT_ALLOWED |
||
149 | ); |
||
150 | } |
||
151 | |||
152 | $this->masterBroadcast(BroadcasterInterface::RESPONSE_EVENT, new ResponseEvent($request, $response)); |
||
153 | } catch (\Throwable $throwable) { |
||
|
|||
154 | $exceptionEvent = new ExceptionEvent($throwable); |
||
155 | $this->masterBroadcast(BroadcasterInterface::EXCEPTION_EVENT, $exceptionEvent); |
||
156 | $response = $exceptionEvent->response(); |
||
157 | } |
||
158 | |||
159 | return $response; |
||
160 | } |
||
161 | |||
162 | /** |
||
163 | * {@inheritdoc} |
||
164 | */ |
||
165 | public function on(string $eventName, $receiver, int $priority = BroadcasterInterface::RECEIVER_NORMAL_PRIORITY) |
||
186 | |||
187 | /** |
||
188 | * {@inheritdoc} |
||
189 | */ |
||
190 | public function broadcast(string $eventName, EventInterface $event = null) |
||
216 | |||
217 | /** |
||
218 | * @param ContainerProviderInterface $provider |
||
219 | * @return self |
||
220 | */ |
||
221 | public function hydrate(ContainerProviderInterface $provider): Jarvis |
||
227 | |||
228 | /** |
||
229 | * Enables master emitter mode. |
||
230 | * |
||
231 | * @return self |
||
232 | */ |
||
233 | private function masterBroadcast(string $eventName, EventInterface $event = null): Jarvis |
||
241 | |||
242 | /** |
||
243 | * Sets new attribute into Jarvis. |
||
244 | * |
||
245 | * @param string $key The name of the new attribute |
||
246 | * @param mixed $value The value of the new attribute |
||
247 | * @return self |
||
248 | */ |
||
249 | private function masterSetter(string $key, $value): Jarvis |
||
257 | |||
258 | /** |
||
259 | * Builds and returns well ordered receivers collection that match with provided event name. |
||
260 | * |
||
261 | * @param string $eventName The event name we want to get its receivers |
||
262 | * @return array |
||
263 | */ |
||
264 | private function buildEventReceivers(string $eventName): array |
||
272 | } |
||
273 |
Scrutinizer analyzes your
composer.json
/composer.lock
file if available to determine the classes, and functions that are defined by your dependencies.It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.