HardCodedSpecification   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 1
dl 0
loc 16
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A isSatisfiedBy() 0 6 1
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace Larium\Specification;
6
7
/**
8
 * HardCodedSpecification class.
9
 *
10
 * Implemented by coding the selection criteria into the isSatisfiedBy method
11
 * as a block of code.
12
 *
13
 * @link https://martinfowler.com/apsupp/spec.pdf Specifications page 8.
14
 * @author Andreas Kollaros <[email protected]>
15
 */
16
final class HardCodedSpecification extends LeafSpecification
17
{
18
    private $callable;
19
20 8
    public function __construct(callable $callable)
21
    {
22 8
        $this->callable = $callable;
23 8
    }
24
25 8
    public function isSatisfiedBy(Candidate $candidate): bool
26
    {
27 8
        $callable = $this->callable;
28
29 8
        return $callable($candidate);
30
    }
31
}
32