AbstractCompareTwo::execute()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 1
dl 0
loc 9
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\Comparator;
9
10
use LogicTree\Operator\OperatorInterface;
11
12
/**
13
 * Class AbstractCompareTwo
14
 */
15
abstract class AbstractCompareTwo implements OperatorInterface
16
{
17
    /**
18
     * {@inheritdoc}
19
     */
20
    public function execute(...$expressions): bool
21
    {
22
        $count = \count($expressions);
23
24
        if ($count !== 2) {
25
            throw new \InvalidArgumentException('2 expressions expected, ' . $count . ' given.');
26
        }
27
28
        return $this->executeComparison($expressions[0], $expressions[1]);
29
    }
30
31
    /**
32
     * Execute the comparison for expressions
33
     *
34
     * @param mixed $expr1
35
     * @param mixed $expr2
36
     * @return bool
37
     */
38
    abstract public function executeComparison($expr1, $expr2): bool;
39
}
40