Issues (1783)

src/gql/interfaces/RetourInterface.php (32 issues)

1
<?php
2
/**
3
 * Retour plugin for Craft CMS
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/
0 ignored issues
show
The tag in position 1 should be the @copyright tag
Loading history...
9
 * @copyright Copyright (c) 2019 nystudio107
0 ignored issues
show
@copyright tag must contain a year and the name of the copyright holder
Loading history...
10
 */
0 ignored issues
show
PHP version not specified
Loading history...
Missing @category tag in file comment
Loading history...
Missing @package tag in file comment
Loading history...
Missing @author tag in file comment
Loading history...
Missing @license tag in file comment
Loading history...
11
12
namespace nystudio107\retour\gql\interfaces;
13
14
use craft\gql\base\InterfaceType as BaseInterfaceType;
15
16
use craft\gql\GqlEntityRegistry;
17
use GraphQL\Type\Definition\InterfaceType;
18
19
use GraphQL\Type\Definition\Type;
20
use nystudio107\retour\gql\types\generators\RetourGenerator;
21
22
/**
23
 * Class RetourInterface
24
 *
25
 * @author    nystudio107
0 ignored issues
show
The tag in position 1 should be the @package tag
Loading history...
Content of the @author tag must be in the form "Display Name <[email protected]>"
Loading history...
Tag value for @author tag indented incorrectly; expected 2 spaces but found 4
Loading history...
26
 * @package   Retour
0 ignored issues
show
Tag value for @package tag indented incorrectly; expected 1 spaces but found 3
Loading history...
27
 * @since     3.1.26
0 ignored issues
show
The tag in position 3 should be the @author tag
Loading history...
Tag value for @since tag indented incorrectly; expected 3 spaces but found 5
Loading history...
28
 */
0 ignored issues
show
Missing @category tag in class comment
Loading history...
Missing @license tag in class comment
Loading history...
Missing @link tag in class comment
Loading history...
29
class RetourInterface extends BaseInterfaceType
30
{
31
    /**
0 ignored issues
show
Missing short description in doc comment
Loading history...
32
     * @inheritdoc
33
     */
0 ignored issues
show
Missing @return tag in function comment
Loading history...
34
    public static function getTypeGenerator(): string
35
    {
36
        return RetourGenerator::class;
37
    }
38
39
    /**
0 ignored issues
show
Missing short description in doc comment
Loading history...
Parameter $fields should have a doc-comment as per coding-style.
Loading history...
40
     * @inheritdoc
41
     */
0 ignored issues
show
Missing @return tag in function comment
Loading history...
42
    public static function getType($fields = null): Type
0 ignored issues
show
The parameter $fields 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

42
    public static function getType(/** @scrutinizer ignore-unused */ $fields = null): Type

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...
43
    {
44
        if ($type = GqlEntityRegistry::getEntity(self::class)) {
45
            return $type;
46
        }
47
48
        $type = GqlEntityRegistry::createEntity(self::class, new InterfaceType([
0 ignored issues
show
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
49
            'name' => static::getName(),
50
            'fields' => self::class . '::getFieldDefinitions',
51
            'description' => 'This is the interface implemented by Retour.',
52
            'resolveType' => function(array $value) {
0 ignored issues
show
The parameter $value 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

52
            'resolveType' => function(/** @scrutinizer ignore-unused */ array $value) {

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...
Expected 1 space after FUNCTION keyword; 0 found
Loading history...
53
                return GqlEntityRegistry::getEntity(RetourGenerator::getName());
54
            },
55
        ]));
0 ignored issues
show
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
56
        RetourGenerator::generateTypes();
57
58
        return $type;
59
    }
60
61
    /**
0 ignored issues
show
Missing short description in doc comment
Loading history...
62
     * @inheritdoc
63
     */
0 ignored issues
show
Missing @return tag in function comment
Loading history...
64
    public static function getName(): string
65
    {
66
        return 'RetourInterface';
67
    }
68
69
    /**
0 ignored issues
show
Missing short description in doc comment
Loading history...
70
     * @inheritdoc
71
     */
0 ignored issues
show
Missing @return tag in function comment
Loading history...
72
    public static function getFieldDefinitions(): array
73
    {
74
        return array_merge(parent::getFieldDefinitions(), [
0 ignored issues
show
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
75
            'id' => [
76
                'name' => 'id',
77
                'type' => Type::int(),
78
                'description' => 'The id of the redirect.',
79
            ],
80
            'site' => [
81
                'name' => 'site',
82
                'type' => Type::string(),
83
                'description' => 'The site handle of the redirect (or null for all sites).',
84
            ],
85
            'siteId' => [
86
                'name' => 'siteId',
87
                'type' => Type::int(),
88
                'description' => 'The siteId of the redirect (0 or null for all sites).',
89
            ],
90
            'associatedElementId' => [
91
                'name' => 'associatedElementId',
92
                'type' => Type::int(),
93
                'description' => 'The id of the Element associated with this redirect (unused/vestigial).',
94
            ],
95
            'enabled' => [
96
                'name' => 'enabled',
97
                'type' => Type::boolean(),
98
                'description' => 'Whether the redirect is enabled or not.',
99
            ],
100
            'redirectSrcUrl' => [
101
                'name' => 'redirectSrcUrl',
102
                'type' => Type::string(),
103
                'description' => 'The unparsed URL pattern that Retour should match.',
104
            ],
105
            'redirectSrcUrlParsed' => [
106
                'name' => 'redirectSrcUrlParsed',
107
                'type' => Type::string(),
108
                'description' => 'The parsed URL pattern that Retour should match.',
109
            ],
110
            'redirectSrcMatch' => [
111
                'name' => 'redirectSrcMatch',
112
                'type' => Type::string(),
113
                'description' => 'Should the legacy URL be matched by path or by full URL?',
114
            ],
115
            'redirectMatchType' => [
116
                'name' => 'redirectMatchType',
117
                'type' => Type::string(),
118
                'description' => 'Whether an `exactmatch` or `regexmatch` should be used when matching the URL.',
119
            ],
120
            'redirectDestUrl' => [
121
                'name' => 'redirectDestUrl',
122
                'type' => Type::string(),
123
                'description' => 'The URL that should be redirected to.',
124
            ],
125
            'redirectHttpCode' => [
126
                'name' => 'redirectHttpCode',
127
                'type' => Type::int(),
128
                'description' => 'The http status code that should be used for the redirect.',
129
            ],
130
            'hitCount' => [
131
                'name' => 'hitCount',
132
                'type' => Type::int(),
133
                'description' => 'The number of times this redirect has been hit.',
134
            ],
135
            'hitLastTime' => [
136
                'name' => 'hitLastTime',
137
                'type' => Type::string(),
138
                'description' => 'A datetime string of when this redirect was last hit.',
139
            ],
140
        ]);
0 ignored issues
show
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
141
    }
142
}
143