Conditions | 3 |
Paths | 2 |
Total Lines | 14 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 3 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
35 | 2 | public function getValue() |
|
36 | { |
||
37 | 2 | $return = ''; |
|
38 | 2 | $options = $this->getOptions(); |
|
39 | 2 | if ($options == self::OPTIONS_ALLOW_FROM) { |
|
40 | 1 | $urls = $this->getUri(); |
|
41 | 1 | foreach ($urls as $url) { |
|
42 | 1 | $return .= $options . ' ' . $url . ';'; |
|
43 | } |
||
44 | } else { |
||
45 | 1 | $return = $options; |
|
46 | } |
||
47 | 2 | return $return; |
|
48 | } |
||
49 | |||
98 |
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.