Completed
Push — master ( 3b79f3...426227 )
by Kirill
03:11
created

ScalarBuilder::build()   B

Complexity

Conditions 6
Paths 6

Size

Total Lines 23
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 6
eloc 14
nc 6
nop 0
dl 0
loc 23
rs 8.5906
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\Adapters\Webonyx\Builders;
11
12
use GraphQL\Type\Definition\Type;
13
use Railt\Reflection\Contracts\Definitions\ScalarDefinition;
0 ignored issues
show
Bug introduced by
The type Railt\Reflection\Contrac...itions\ScalarDefinition was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
14
use Railt\Reflection\Standard\Scalars\BooleanType;
0 ignored issues
show
Bug introduced by
The type Railt\Reflection\Standard\Scalars\BooleanType was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
15
use Railt\Reflection\Standard\Scalars\FloatType;
0 ignored issues
show
Bug introduced by
The type Railt\Reflection\Standard\Scalars\FloatType was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
16
use Railt\Reflection\Standard\Scalars\IDType;
0 ignored issues
show
Bug introduced by
The type Railt\Reflection\Standard\Scalars\IDType was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
17
use Railt\Reflection\Standard\Scalars\IntType;
0 ignored issues
show
Bug introduced by
The type Railt\Reflection\Standard\Scalars\IntType was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
18
use Railt\Reflection\Standard\Scalars\StringType;
0 ignored issues
show
Bug introduced by
The type Railt\Reflection\Standard\Scalars\StringType was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
19
20
/**
21
 * @property ScalarDefinition $reflection
22
 */
23
class ScalarBuilder extends TypeBuilder
24
{
25
    /**
26
     * @return Type
27
     * @throws \InvalidArgumentException
28
     */
29
    public function build(): Type
30
    {
31
        $class = \get_class($this->reflection);
32
33
        switch ($class) {
34
            case StringType::class:
35
                return Type::string();
36
37
            case IDType::class:
38
                return Type::id();
39
40
            case BooleanType::class:
41
                return Type::boolean();
42
43
            case IntType::class:
44
                return Type::int();
45
46
            case FloatType::class:
47
                return Type::float();
48
        }
49
50
        $error = 'Can not build scalar type %s.';
51
        throw new \InvalidArgumentException(\sprintf($error, $this->reflection));
52
    }
53
}
54