OrOperator::execute()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 3
eloc 5
nc 3
nop 1
dl 0
loc 10
rs 10
c 1
b 0
f 1
1
<?php
2
/**
3
 * Copyright © 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
use function count;
12
13
/**
14
 * The OR:
15
 * The output is "true" if either or both of the inputs are "true".
16
 * If both inputs are "false," then the output is "false".
17
 */
18
final class OrOperator implements OperatorInterface
19
{
20
    public const CODE = 'or';
21
22
    public function execute(...$expressions): bool
23
    {
24
        $count = count($expressions);
25
        $result = $expressions[0];
26
27
        for ($i = 1; $i < $count; $i++) {
28
            $result = $result || $expressions[$i];
29
        }
30
31
        return $result;
32
    }
33
}
34