AbstractCompareTwo   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 2
eloc 4
c 1
b 0
f 1
dl 0
loc 21
rs 10

1 Method

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