1 | <?php |
||
11 | abstract class AbstractSpecConfig extends AbstractConfig implements |
||
12 | FeatureInterface |
||
13 | { |
||
14 | /** |
||
15 | * Spec key |
||
16 | * |
||
17 | * @var string |
||
18 | */ |
||
19 | private $name; |
||
20 | |||
21 | /** |
||
22 | * @param string $name |
||
23 | */ |
||
24 | public function __construct($name) |
||
28 | |||
29 | /** |
||
30 | * @return mixed |
||
31 | */ |
||
32 | public function getName() |
||
36 | |||
37 | /** |
||
38 | * @param string $locator |
||
39 | * @return $this |
||
40 | */ |
||
41 | public function setLocator($locator) |
||
46 | |||
47 | /** |
||
48 | * @param int $priority |
||
49 | * @return $this |
||
50 | */ |
||
51 | public function setPriority($priority) |
||
56 | |||
57 | /** |
||
58 | * @param array $options |
||
59 | * @return $this |
||
60 | */ |
||
61 | public function setOptions(array $options) |
||
66 | |||
67 | /** |
||
68 | * {@inheritdoc} |
||
69 | */ |
||
70 | public function toArray() |
||
76 | } |
||
77 |
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.