Test Failed
Push — master ( b7ab7b...94ee03 )
by Kirill
02:59
created

RuntimeTypes::getRuntimeTypes()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 22

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 22
ccs 0
cts 8
cp 0
crap 2
rs 9.568
c 0
b 0
f 0
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\IR\Type\InternalTypes;
11
12
use Railt\SDL\IR\Type;
13
use Railt\SDL\IR\Type\TypeInterface;
14
15
/**
16
 * Trait RuntimeTypes
17
 */
18
trait RuntimeTypes
19
{
20
    /**
21
     * @return array|TypeInterface[]
22
     */
23
    protected static function getRuntimeTypes(): array
24
    {
25
        return [
26
            //
27
            // NOTE: It is worth noting that the ID, DateTime and others
28
            // are not independent types that can be deduced during the
29
            // early static binding.
30
            //
31
            // In particular, the type of the ID can be derived from a
32
            // String or any Int or Float. The hierarchy of scalars
33
            // determines only the situation when a type can be converted
34
            // to a parent without losing a piece of data.
35
            //
36
            self::STRING    => $string = self::createInternalType(self::STRING, Type::scalar()),
37
            self::FLOAT     => $float = self::createInternalType(self::FLOAT, $string),
38
            self::INT       => $int = self::createInternalType(self::INT, $float),
39
            self::BOOLEAN   => $bool = self::createInternalType(self::BOOLEAN, $string),
40
            self::NULL      => $null = self::createInternalType(self::NULL, Type::scalar()),
41
            self::ID        => $id = self::createInternalType(self::ID, $string),
42
            self::DATE_TIME => $date = self::createInternalType(self::DATE_TIME, $string),
43
        ];
44
    }
45
}
46