1 | <?php |
||
13 | class RepostOnTimeOutProcessor implements ProcessorInterface |
||
14 | { |
||
15 | protected $processor; |
||
16 | protected $messageProvider; |
||
17 | protected $logger; |
||
18 | |||
19 | /** |
||
20 | * @param ProcessorInterface $processor Processor |
||
21 | * @param MessageProviderInterface $messageProvider Message provider |
||
22 | * @param LoggerInterface $logger Logger |
||
23 | */ |
||
24 | public function __construct(ProcessorInterface $processor, MessageProviderInterface $messageProvider, LoggerInterface $logger = null) |
||
30 | |||
31 | /** |
||
32 | * {@inheritdoc} |
||
33 | */ |
||
34 | public function process(Message $message, array $options) |
||
55 | |||
56 | } |
||
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.