1 | <?php |
||
8 | class Inspector |
||
9 | { |
||
10 | /** |
||
11 | * @var array |
||
12 | */ |
||
13 | protected $excludeScopes = ['scopeScope', 'scopeEloquentJs']; |
||
14 | |||
15 | /** |
||
16 | * @var Repository |
||
17 | */ |
||
18 | protected $config; |
||
19 | |||
20 | /** |
||
21 | * Create a new Inspector instance. |
||
22 | * |
||
23 | * @param Repository $config |
||
24 | */ |
||
25 | public function __construct(Repository $config) |
||
29 | |||
30 | /** |
||
31 | * Inspect a model class and return its metadata. |
||
32 | * |
||
33 | * @param Model $instance |
||
34 | * @return Metadata |
||
35 | */ |
||
36 | public function inspect(Model $instance) |
||
45 | |||
46 | /** |
||
47 | * Find the endpoint for this model. |
||
48 | * |
||
49 | * @param Model $instance |
||
50 | * @return string|null |
||
51 | */ |
||
52 | protected function findEndpoint(Model $instance) |
||
60 | |||
61 | /** |
||
62 | * Get any additional date columns for this model. |
||
63 | * |
||
64 | * @param Model $instance |
||
65 | * @return array |
||
66 | */ |
||
67 | protected function findDateColumns(Model $instance) |
||
73 | |||
74 | /** |
||
75 | * Get the scope methods for this model with 'scope' prefix removed. |
||
76 | * |
||
77 | * @param Model $instance |
||
78 | * @return array |
||
79 | */ |
||
80 | protected function findScopeMethods(Model $instance) |
||
96 | |||
97 | /** |
||
98 | * Read from a model config value from the eloquentjs.php config file. |
||
99 | * |
||
100 | * @param Model $instance |
||
101 | * @param string $key |
||
102 | * @return mixed |
||
103 | */ |
||
104 | protected function readModelConfig(Model $instance, $key) |
||
110 | } |
||
111 |
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.