Completed
Push — master ( c256c8...c86654 )
by Thomas
02:26
created

NorOperator   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 17
rs 10
c 0
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A execute() 0 10 3
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 NorOperator
14
 *
15
 * The NOR:
16
 * The output is "true" if both inputs are "false". Otherwise, the output is "false".
17
 */
18
final class NorOperator implements OperatorInterface
19
{
20
    public const CODE = 'nor';
21
22
    /**
23
     * {@inheritdoc}
24
     */
25
    public function execute(...$expressions): bool
26
    {
27
        $count = count($expressions);
28
        $result = $expressions[0];
29
30
        for ($i = 1; $i < $count; $i++) {
31
            $result = !($result || $expressions[$i]);
32
        }
33
34
        return $result;
35
    }
36
}
37