AbstractCompareOne   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 23
rs 10
c 0
b 0
f 0
wmc 2

1 Method

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