1 | <?php |
||
18 | abstract class AbstractRoom implements RoomInterface |
||
19 | { |
||
20 | /** |
||
21 | * @var string |
||
22 | */ |
||
23 | protected $id; |
||
24 | |||
25 | /** |
||
26 | * @var string |
||
27 | */ |
||
28 | protected $alias; |
||
29 | |||
30 | /** |
||
31 | * @var array |
||
32 | */ |
||
33 | protected $groups; |
||
34 | |||
35 | /** |
||
36 | * @var \Domains\Middleware\Storage |
||
37 | */ |
||
38 | protected $middleware; |
||
39 | |||
40 | /** |
||
41 | * @var ClientInterface |
||
42 | */ |
||
43 | protected $client; |
||
44 | |||
45 | /** |
||
46 | * @var Application |
||
47 | */ |
||
48 | protected $app; |
||
49 | |||
50 | public function __construct() |
||
62 | |||
63 | /** |
||
64 | * @return string |
||
65 | */ |
||
66 | public function id() |
||
70 | |||
71 | /** |
||
72 | * @return string |
||
73 | */ |
||
74 | public function alias() |
||
78 | |||
79 | /** |
||
80 | * @return array |
||
81 | */ |
||
82 | public function groups() |
||
86 | |||
87 | /** |
||
88 | * @return ClientInterface |
||
89 | */ |
||
90 | public function client() |
||
94 | |||
95 | /** |
||
96 | * @return \Domains\Middleware\Storage |
||
97 | */ |
||
98 | public function middleware() |
||
102 | |||
103 | /** |
||
104 | * Create subscribers storage |
||
105 | */ |
||
106 | protected function createSubscribersStorage() |
||
119 | |||
120 | /** |
||
121 | * Create middleware storage |
||
122 | * |
||
123 | * @param array $groups |
||
124 | */ |
||
125 | protected function setMiddleware(array $groups) |
||
142 | |||
143 | /** |
||
144 | * @return Client |
||
145 | */ |
||
146 | public function listen() |
||
150 | |||
151 | /** |
||
152 | * @param string $message |
||
153 | * @return $this |
||
154 | */ |
||
155 | public function sendMessage($message) |
||
159 | } |
PHP has two types of connecting operators (logical operators, and boolean operators):
and
&&
or
||
The difference between these is the order in which they are executed. In most cases, you would want to use a boolean operator like
&&
, or||
.Let’s take a look at a few examples:
Logical Operators are used for Control-Flow
One case where you explicitly want to use logical operators is for control-flow such as this:
Since
die
introduces problems of its own, f.e. it makes our code hardly testable, and prevents any kind of more sophisticated error handling; you probably do not want to use this in real-world code. Unfortunately, logical operators cannot be combined withthrow
at this point:These limitations lead to logical operators rarely being of use in current PHP code.