1 | <?php |
||
10 | abstract class Protocol |
||
11 | { |
||
12 | /** @var Model|\MadWeb\Seoable\Contracts\Seoable */ |
||
13 | protected $model; |
||
14 | |||
15 | /** @var array */ |
||
16 | protected $modelSeoData; |
||
17 | |||
18 | /** @var \Artesaos\SEOTools\SEOMeta */ |
||
19 | protected $metaService = null; |
||
20 | |||
21 | /** @var \Artesaos\SEOTools\OpenGraph */ |
||
22 | protected $openGraphService = null; |
||
23 | |||
24 | /** @var \Artesaos\SEOTools\TwitterCards */ |
||
25 | protected $twitterCardService = null; |
||
26 | |||
27 | /** @var \Artesaos\SEOTools\SEOTools */ |
||
28 | protected $seoTools = null; |
||
29 | |||
30 | protected $isRaw = false; |
||
31 | |||
32 | protected $isStoredFieldsIgnores = false; |
||
33 | |||
34 | /** @param Model|\MadWeb\Seoable\Contracts\Seoable $model */ |
||
35 | public function __construct(Seoable $model) |
||
45 | |||
46 | /** |
||
47 | * @param array|string $value |
||
48 | * @param \MadWeb\Seoable\Fields\Field|string $type |
||
49 | * @return mixed |
||
50 | */ |
||
51 | protected function parseValue($value, $type) |
||
63 | |||
64 | public function __call($name, $arguments) |
||
76 | |||
77 | public function twitter(): TwitterCard |
||
81 | |||
82 | public function opengraph(): OpenGraph |
||
86 | |||
87 | public function meta(): Meta |
||
91 | |||
92 | public function ignoreStored() |
||
98 | |||
99 | abstract protected function getRawFields(): array; |
||
100 | } |
||
101 |
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.