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) |
||
46 | |||
47 | /** |
||
48 | * Find the endpoint for this model. |
||
49 | * |
||
50 | * @param Model $instance |
||
51 | * @return string|null |
||
52 | */ |
||
53 | protected function findEndpoint(Model $instance) |
||
61 | |||
62 | /** |
||
63 | * Get any additional date columns for this model. |
||
64 | * |
||
65 | * @param Model $instance |
||
66 | * @return array |
||
67 | */ |
||
68 | protected function findDateColumns(Model $instance) |
||
74 | |||
75 | /** |
||
76 | * Get the scope methods for this model with 'scope' prefix removed. |
||
77 | * |
||
78 | * @param Model $instance |
||
79 | * @return array |
||
80 | */ |
||
81 | protected function findScopeMethods(Model $instance) |
||
97 | |||
98 | /** |
||
99 | * Get a map of relation method names and their related models. |
||
100 | * |
||
101 | * For example, if the given model has a "comments" method that |
||
102 | * describes the relation to a Comment model, this returns |
||
103 | * ['comments' => 'Comment'] |
||
104 | * |
||
105 | * @param Model $instance |
||
106 | * @return array |
||
107 | */ |
||
108 | protected function findRelations(Model $instance) |
||
114 | |||
115 | /** |
||
116 | * Read from a model config value from the eloquentjs.php config file. |
||
117 | * |
||
118 | * @param Model $instance |
||
119 | * @param string $key |
||
120 | * @param mixed $default |
||
121 | * @return mixed |
||
122 | */ |
||
123 | protected function readModelConfig(Model $instance, $key, $default = null) |
||
129 | } |
||
130 |
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.