1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Webino (http://webino.sk) |
4
|
|
|
* |
5
|
|
|
* @link https://github.com/webino for the canonical source repository |
6
|
|
|
* @copyright Copyright (c) 2015-2017 Webino, s.r.o. (http://webino.sk) |
7
|
|
|
* @author Peter Bačinský <[email protected]> |
8
|
|
|
* @license BSD-3-Clause |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace WebinoConfigLib\Feature\Route; |
12
|
|
|
|
13
|
|
|
use WebinoConfigLib\Feature\Route as BaseRoute; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Class Console |
17
|
|
|
*/ |
18
|
|
|
class ConsoleRoute extends BaseRoute |
19
|
|
|
{ |
20
|
|
|
/** |
21
|
|
|
* {@inheritdoc} |
22
|
|
|
*/ |
23
|
|
|
public function __construct($name = null) |
24
|
|
|
{ |
25
|
|
|
parent::__construct($name); |
26
|
|
|
$this->setType($this::SIMPLE); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* {@inheritdoc} |
31
|
|
|
*/ |
32
|
|
|
public function setPath($path) |
33
|
|
|
{ |
34
|
|
|
parent::setPath(is_array($path) ? join(' ', $path) : $path); |
35
|
|
|
return $this; |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* Set route title |
40
|
|
|
* |
41
|
|
|
* @param string $title |
42
|
|
|
* @return $this |
43
|
|
|
*/ |
44
|
|
|
public function setTitle($title) |
45
|
|
|
{ |
46
|
|
|
$this->setDefaults(['title' => (string) $title]); |
47
|
|
|
return $this; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* Set route description |
52
|
|
|
* |
53
|
|
|
* @param string|array $description |
54
|
|
|
* @return $this |
55
|
|
|
*/ |
56
|
|
|
public function setDescription($description) |
57
|
|
|
{ |
58
|
|
|
is_array($description) |
59
|
|
|
and $description = join(PHP_EOL, $description) ; |
|
|
|
|
60
|
|
|
|
61
|
|
|
$this->setDefaults(['description' => $description]); |
62
|
|
|
return $this; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* @param array $description |
67
|
|
|
* @return $this |
68
|
|
|
*/ |
69
|
|
|
public function setArgumentsDescription($description) |
70
|
|
|
{ |
71
|
|
|
$this->setDefaults(['argumentsDescription' => $description]); |
72
|
|
|
return $this; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* @param array $description |
77
|
|
|
* @return $this |
78
|
|
|
*/ |
79
|
|
|
public function setOptionsDescription($description) |
80
|
|
|
{ |
81
|
|
|
$this->setDefaults(['optionsDescription' => $description]); |
82
|
|
|
return $this; |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* {@inheritdoc} |
87
|
|
|
*/ |
88
|
|
|
public function toArray() |
89
|
|
|
{ |
90
|
|
|
return ['console' => parent::toArray()]; |
91
|
|
|
} |
92
|
|
|
} |
93
|
|
|
|
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.