AbstractCompareOne   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
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 20
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 AbstractCompareOne implements OperatorInterface
15
{
16
    public function execute(...$expressions): bool
17
    {
18
        $count = count($expressions);
19
20
        if ($count !== 1) {
21
            throw new InvalidArgumentException('1 expression expected, ' . $count . ' given.');
22
        }
23
24
        return $this->executeComparison($expressions[0]);
25
    }
26
27
    /**
28
     * Execute the comparison for the expression
29
     *
30
     * @param mixed $expression
31
     * @return bool
32
     */
33
    abstract public function executeComparison($expression): bool;
34
}
35