Test Failed
Push — master ( d59132...fd300c )
by Kirill
03:01
created

DirectiveLocation::isBuiltin()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
ccs 0
cts 2
cp 0
rs 10
cc 1
nc 1
nop 0
crap 2
1
<?php
2
/**
3
 * This file is part of Railt package.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
declare(strict_types=1);
9
10
namespace Railt\Reflection\Definition\Dependent;
11
12
use Railt\Reflection\Contracts\Definition\Dependent\DirectiveLocation as DirectiveLocationInterface;
13
use Railt\Reflection\Contracts\TypeInterface;
14
use Railt\Reflection\Type;
15
16
/**
17
 * Class DirectiveLocation
18
 */
19
class DirectiveLocation extends AbstractDependentTypeDefinition implements DirectiveLocationInterface
20
{
21
    /**
22
     * @return TypeInterface
23
     */
24
    public static function getType(): TypeInterface
25
    {
26
        return Type::of(Type::DIRECTIVE_LOCATION);
27
    }
28
29
    /**
30
     * @return bool
31
     */
32
    public function isExecutable(): bool
33
    {
34
        return \in_array($this->getName(), static::EXECUTABLE_LOCATIONS, true);
35
    }
36
37
    /**
38
     * @return bool
39
     */
40
    public function isPrivate(): bool
41
    {
42
        return \in_array($this->getName(), static::SDL_LOCATIONS, true);
43
    }
44
45
    /**
46
     * @param TypeInterface $type
47
     * @return bool
48
     */
49
    public function isAllowedFor(TypeInterface $type): bool
50
    {
51
        $location = static::LOCATION_TO_TYPES[$this->getName()] ?? Type::ANY;
52
53
        return $type->instanceOf(Type::of($location));
54
    }
55
56
    /**
57
     * @return bool
58
     */
59
    public function isBuiltin(): bool
60
    {
61
        return true;
62
    }
63
}
64