1 | <?php |
||
8 | class Run implements Runner |
||
9 | { |
||
10 | protected $commands = []; |
||
11 | |||
12 | 24 | public function artisan(string $command, array $arguments = []): Runner |
|
18 | |||
19 | 6 | public function external(string $command, ...$arguments): Runner |
|
25 | |||
26 | 3 | public function callable(callable $function, ...$arguments): Runner |
|
32 | |||
33 | 27 | public function dispatch($job): Runner |
|
39 | |||
40 | 6 | public function dispatchNow($job): Runner |
|
46 | |||
47 | 24 | public function publish($providers): Runner |
|
48 | { |
||
49 | 24 | if (is_string($providers)) { |
|
50 | 3 | $this->artisan('vendor:publish', ['--provider' => $providers]); |
|
51 | 21 | } elseif (is_array($providers)) { |
|
52 | 18 | foreach ($providers as $provider => $tag) { |
|
53 | 18 | $arguments = []; |
|
54 | |||
55 | 18 | $arguments['--provider'] = is_numeric($provider) ? $tag : $provider; |
|
56 | |||
57 | 18 | if (! is_numeric($provider) and is_string($tag)) { |
|
|
|||
58 | 12 | $arguments['--tag'] = $tag; |
|
59 | } |
||
60 | |||
61 | 18 | $this->artisan('vendor:publish', $arguments); |
|
62 | } |
||
63 | } else { |
||
64 | 3 | throw new InvalidArgumentException('Invalid publishable argument.'); |
|
65 | } |
||
66 | |||
67 | 21 | return $this; |
|
68 | } |
||
69 | |||
70 | 63 | protected function pushCommand(string $type, $command, array $arguments = []) |
|
74 | |||
75 | 63 | public function getCommands(): array |
|
79 | } |
||
80 |
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.