Completed
Push — master ( 5ac91e...39483e )
by Kirill
38:30
created

BaseScalar   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 0
loc 37
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getTypeName() 0 4 1
A isCompatible() 0 4 1
A __sleep() 0 7 1
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\SDL\Base\Definitions;
11
12
use Railt\SDL\Base\Invocations\Directive\BaseDirectivesContainer;
13
use Railt\SDL\Contracts\Definitions\ScalarDefinition;
14
use Railt\SDL\Contracts\Type;
15
16
/**
17
 * Class BaseScalar
18
 */
19
abstract class BaseScalar extends BaseTypeDefinition implements ScalarDefinition
20
{
21
    use BaseDirectivesContainer;
22
23
    /**
24
     * Object type name
25
     */
26
    protected const TYPE_NAME = Type::SCALAR;
27
28
    /**
29
     * @return string
30
     */
31 567
    public function getTypeName(): string
32
    {
33 567
        return static::TYPE_NAME;
34
    }
35
36
    /**
37
     * @param mixed $value
38
     * @return bool
39
     */
40 318
    public function isCompatible($value): bool
41
    {
42 318
        return true;
43
    }
44
45
    /**
46
     * @return array
47
     */
48 1222
    public function __sleep(): array
49
    {
50 1222
        return \array_merge(parent::__sleep(), [
51
            // trait HasDirectives
52 1222
            'directives',
53
        ]);
54
    }
55
}
56