Conditions | 3 |
Paths | 3 |
Total Lines | 21 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
34 | public function process(Message $message, array $options) |
||
35 | { |
||
36 | $return = $this->processor->process($message, $options); |
||
37 | |||
38 | if (false === $return) { |
||
39 | $this->messageProvider->nack($message, true); |
||
40 | |||
41 | $this->logger and $this->logger->info( |
||
|
|||
42 | sprintf( |
||
43 | '[Repost] A timeout occurred. Message #%d has been %s.', |
||
44 | $message->getId(), |
||
45 | 'requeued' |
||
46 | ), |
||
47 | [ |
||
48 | 'swarrot_processor' => 'repost', |
||
49 | ] |
||
50 | ); |
||
51 | } |
||
52 | |||
53 | return $return; |
||
54 | } |
||
55 | |||
57 |
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.