1 | <?php |
||
11 | class OriginCheck implements HttpServerInterface |
||
12 | { |
||
13 | use CloseResponseTrait; |
||
14 | |||
15 | /** @var \Ratchet\MessageComponentInterface */ |
||
16 | protected $_component; |
||
17 | |||
18 | protected $allowedOrigins = []; |
||
19 | |||
20 | public function __construct(MessageComponentInterface $component, array $allowedOrigins = []) |
||
26 | |||
27 | public function onOpen(ConnectionInterface $connection, RequestInterface $request = null) |
||
35 | |||
36 | public function onMessage(ConnectionInterface $from, $msg) |
||
40 | |||
41 | public function onClose(ConnectionInterface $connection) |
||
45 | |||
46 | public function onError(ConnectionInterface $connection, \Exception $e) |
||
50 | |||
51 | protected function verifyOrigin(ConnectionInterface $connection, RequestInterface $request) |
||
60 | } |
||
61 |
If a variable is not always an object, we recommend to add an additional type check to ensure your method call is safe: