Passed
Push — master ( 6137ca...01151b )
by Kevin
02:21
created

ClassMethodMap::classInMap()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2.0625

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 2
eloc 3
c 1
b 0
f 1
nc 2
nop 1
dl 0
loc 7
ccs 3
cts 4
cp 0.75
crap 2.0625
rs 10
1
<?php
2
3
namespace Zenstruck\Porpaginas\Specification\Normalizer;
4
5
/**
6
 * @author Kevin Bond <[email protected]>
7
 */
8
trait ClassMethodMap
9
{
10 26
    protected static function classInMap($specification): bool
11
    {
12 26
        if (!\is_object($specification)) {
13
            return false;
14
        }
15
16 26
        return \array_key_exists(\get_class($specification), static::classMethodMap());
17
    }
18
19 66
    protected static function methodFor(object $specification): string
20
    {
21 66
        return static::classMethodMap()[\get_class($specification)];
22
    }
23
24
    /**
25
     * @return array<string, string>
26
     */
27
    abstract protected static function classMethodMap(): array;
28
29 26
    protected function supportsSpecification($specification): bool
30
    {
31 26
        return self::classInMap($specification);
32
    }
33
}
34