Passed
Push — v3 ( 3d31db...9e8c74 )
by Andrew
29:00 queued 05:41
created

RetourGenerator::getName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 1
1
<?php
2
/**
3
 * Retour plugin for Craft CMS 3.x
4
 *
5
 * Retour allows you to intelligently redirect legacy URLs, so that you don't
6
 * lose SEO value when rebuilding & restructuring a website
7
 *
8
 * @link      https://nystudio107.com/
9
 * @copyright Copyright (c) 2019 nystudio107
10
 */
11
12
namespace nystudio107\retour\gql\types\generators;
13
14
use nystudio107\retour\gql\arguments\RetourArguments;
15
use nystudio107\retour\gql\interfaces\RetourInterface;
16
use nystudio107\retour\gql\types\RetourType;
17
18
use craft\gql\base\GeneratorInterface;
19
use craft\gql\GqlEntityRegistry;
20
use craft\gql\TypeLoader;
21
22
/**
23
 * Class RetourGenerator
24
 *
25
 * @author    nystudio107
26
 * @package   Retour
27
 * @since     3.1.26
28
 */
29
class RetourGenerator implements GeneratorInterface
30
{
31
32
    /**
33
     * @inheritdoc
34
     */
35
    public static function generateTypes($context = null): array
36
    {
37
        $retourFields = RetourInterface::getFieldDefinitions();
38
        $retourArgs = RetourArguments::getArguments();
39
        $typeName = self::getName();
40
        $retourType = GqlEntityRegistry::getEntity($typeName)
41
            ?: GqlEntityRegistry::createEntity($typeName, new RetourType([
42
                'name' => $typeName,
43
                'args' => function () use ($retourArgs) {
44
                    return $retourArgs;
45
                },
46
                'fields' => function () use ($retourFields) {
47
                    return $retourFields;
48
                },
49
                'description' => 'This entity has all the Retour fields',
50
            ]));
51
52
        TypeLoader::registerType($typeName, function () use ($retourType) {
53
            return $retourType;
54
        });
55
56
        return [$retourType];
57
    }
58
59
    /**
60
     * @inheritdoc
61
     */
62
    public static function getName($context = null): string
0 ignored issues
show
Unused Code introduced by
The parameter $context 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

62
    public static function getName(/** @scrutinizer ignore-unused */ $context = null): 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...
63
    {
64
        return 'retour';
65
    }
66
}
67