OrOperator::execute()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 5
nc 3
nop 1
dl 0
loc 10
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Copyright © 2018 Thomas Klein, All rights reserved.
4
 * See LICENSE bundled with this library for license details.
5
 */
6
declare(strict_types=1);
7
8
namespace LogicTree\Operator\Logical;
9
10
use LogicTree\Operator\OperatorInterface;
11
12
/**
13
 * Class OrOperator
14
 *
15
 * The OR:
16
 * The output is "true" if either or both of the inputs are "true".
17
 * If both inputs are "false," then the output is "false".
18
 */
19
final class OrOperator implements OperatorInterface
20
{
21
    public const CODE = 'or';
22
23
    /**
24
     * {@inheritdoc}
25
     */
26
    public function execute(...$expressions): bool
27
    {
28
        $count = \count($expressions);
29
        $result = $expressions[0];
30
31
        for ($i = 1; $i < $count; $i++) {
32
            $result = $result || $expressions[$i];
33
        }
34
35
        return $result;
36
    }
37
}
38