Failed Conditions
Pull Request — master (#10)
by Adrien
02:25
created

AbstractOperator::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
ccs 2
cts 2
cp 1
cc 1
eloc 1
nc 1
nop 1
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace GraphQL\Doctrine\Definition\Operator;
6
7
use Doctrine\ORM\QueryBuilder;
8
use GraphQL\Doctrine\Factory\UniqueNameFactory;
9
use GraphQL\Doctrine\Utils;
10
use GraphQL\Type\Definition\InputObjectType;
11
use GraphQL\Type\Definition\LeafType;
12
use GraphQL\Type\Definition\Type;
13
14
abstract class AbstractOperator extends InputObjectType
15
{
16 6
    public function __construct(LeafType $type)
17
    {
18 6
        parent::__construct($this->getSingleValueConfiguration($type));
19 6
    }
20
21 6
    public function getFieldName(): string
22
    {
23 6
        $class = new \ReflectionClass($this);
24 6
        $name = preg_replace('~OperatorType$~', '', Utils::getTypeName($class->getShortName()));
25
26 6
        return lcfirst($name);
27
    }
28
29 6
    protected function getSingleValueConfiguration(LeafType $type): array
30
    {
31
        return [
32 6
            'name' => Utils::getOperatorTypeName(get_class($this), $type),
33
            'fields' => [
34 6
                'value' => Type::nonNull($type),
35
            ],
36
        ];
37
    }
38
39
    public function getDqlCondition(UniqueNameFactory $uniqueNameFactory, QueryBuilder $queryBuilder, string $alias, string $field, array $config): string
0 ignored issues
show
Unused Code introduced by
The parameter $queryBuilder is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

39
    public function getDqlCondition(UniqueNameFactory $uniqueNameFactory, /** @scrutinizer ignore-unused */ QueryBuilder $queryBuilder, string $alias, string $field, array $config): string

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $config is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

39
    public function getDqlCondition(UniqueNameFactory $uniqueNameFactory, QueryBuilder $queryBuilder, string $alias, string $field, /** @scrutinizer ignore-unused */ array $config): string

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $uniqueNameFactory is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

39
    public function getDqlCondition(/** @scrutinizer ignore-unused */ UniqueNameFactory $uniqueNameFactory, QueryBuilder $queryBuilder, string $alias, string $field, array $config): string

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $alias is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

39
    public function getDqlCondition(UniqueNameFactory $uniqueNameFactory, QueryBuilder $queryBuilder, /** @scrutinizer ignore-unused */ string $alias, string $field, array $config): string

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $field is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

39
    public function getDqlCondition(UniqueNameFactory $uniqueNameFactory, QueryBuilder $queryBuilder, string $alias, /** @scrutinizer ignore-unused */ string $field, array $config): string

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
40
    {
41
        return 'NOT IMPLEMENTED' . get_class($this);
42
    }
43
}
44