| Conditions | 2 |
| Paths | 2 |
| Total Lines | 16 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 30 | public function labels($label_values) |
||
| 31 | { |
||
| 32 | if (count($this->labels) != count($label_values)) { |
||
| 33 | throw new Exceptions\LabelValueMismatch(sprintf( |
||
| 34 | "labels/value counts don't match (%d/%d)", |
||
| 35 | count($this->labels), |
||
| 36 | count($label_values) |
||
| 37 | )); |
||
| 38 | } |
||
| 39 | return new $this->metric_class( |
||
| 40 | $this->var, |
||
| 41 | $this->help, |
||
| 42 | $this->labels, |
||
| 43 | $label_values |
||
| 44 | ); |
||
| 45 | } |
||
| 46 | } |
||
| 49 |
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
dieintroduces 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 withthrowat this point:These limitations lead to logical operators rarely being of use in current PHP code.