Completed
Push — master ( 6173d9...210649 )
by Neomerx
04:26
created

JsonApiBaseController::updateInRelationship()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 32

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 19
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 32
ccs 19
cts 19
cp 1
rs 9.408
c 0
b 0
f 0
cc 1
nc 1
nop 8
crap 1

How to fix   Many Parameters   

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

1
<?php namespace Limoncello\Flute\Http;
2
3
/**
4
 * Copyright 2015-2018 [email protected]
5
 *
6
 * Licensed under the Apache License, Version 2.0 (the "License");
7
 * you may not use this file except in compliance with the License.
8
 * You may obtain a copy of the License at
9
 *
10
 * http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing, software
13
 * distributed under the License is distributed on an "AS IS" BASIS,
14
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
 * See the License for the specific language governing permissions and
16
 * limitations under the License.
17
 */
18
19
use Limoncello\Contracts\Data\ModelSchemaInfoInterface;
20
use Limoncello\Contracts\L10n\FormatterFactoryInterface;
21
use Limoncello\Contracts\Settings\SettingsProviderInterface;
22
use Limoncello\Flute\Contracts\Encoder\EncoderInterface;
23
use Limoncello\Flute\Contracts\FactoryInterface;
24
use Limoncello\Flute\Contracts\Http\JsonApiControllerInterface;
25
use Limoncello\Flute\Contracts\Schema\JsonSchemasInterface;
26
use Limoncello\Flute\Http\Traits\DefaultControllerMethodsTrait;
27
use Psr\Container\ContainerExceptionInterface;
28
use Psr\Container\ContainerInterface;
29
use Psr\Container\NotFoundExceptionInterface;
30
use Psr\Http\Message\ResponseInterface;
31
use Psr\Http\Message\ServerRequestInterface;
32
33
/**
34
 * @package Limoncello\Flute
35
 */
36
abstract class JsonApiBaseController implements JsonApiControllerInterface
37
{
38
    use DefaultControllerMethodsTrait;
39
40
    /** API class name */
41
    const API_CLASS = null;
42
43
    /** JSON API Schema class name */
44
    const SCHEMA_CLASS = null;
45
46
    /** JSON API query validation rules class */
47
    const ON_INDEX_QUERY_VALIDATION_RULES_CLASS = null;
48
49
    /** JSON API query validation rules class */
50
    const ON_READ_QUERY_VALIDATION_RULES_CLASS = null;
51
52
    /** JSON API data validation rules class */
53
    const ON_CREATE_DATA_VALIDATION_RULES_CLASS = null;
54
55
    /** JSON API data validation rules class */
56
    const ON_UPDATE_DATA_VALIDATION_RULES_CLASS = null;
57
58
    /**
59
     * @inheritdoc
60
     */
61 12 View Code Duplication
    public static function index(
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
62
        array $routeParams,
63
        ContainerInterface $container,
64
        ServerRequestInterface $request
65
    ): ResponseInterface {
66 12
        static::assertClassValueDefined(static::API_CLASS);
0 ignored issues
show
Bug introduced by
Since assertClassValueDefined() is declared private, calling it with static will lead to errors in possible sub-classes. You can either use self, or increase the visibility of assertClassValueDefined() to at least protected.

Let’s assume you have a class which uses late-static binding:

class YourClass
{
    private static function getTemperature() {
        return "3422 °C";
}

public static function getSomeVariable()
{
    return static::getTemperature();
}

}

The code above will run fine in your PHP runtime. However, if you now create a sub-class and call the getSomeVariable() on that sub-class, you will receive a runtime error:

class YourSubClass extends YourClass {
      private static function getTemperature() {
        return "-182 °C";
    }
}

print YourSubClass::getSomeVariable(); // Will cause an access error.

In the case above, it makes sense to update SomeClass to use self instead:

class YourClass
{
    private static function getTemperature() {
        return "3422 °C";
    }

    public static function getSomeVariable()
    {
        return self::getTemperature();
    }
}
Loading history...
67 12
        static::assertClassValueDefined(static::SCHEMA_CLASS);
0 ignored issues
show
Bug introduced by
Since assertClassValueDefined() is declared private, calling it with static will lead to errors in possible sub-classes. You can either use self, or increase the visibility of assertClassValueDefined() to at least protected.

Let’s assume you have a class which uses late-static binding:

class YourClass
{
    private static function getTemperature() {
        return "3422 °C";
}

public static function getSomeVariable()
{
    return static::getTemperature();
}

}

The code above will run fine in your PHP runtime. However, if you now create a sub-class and call the getSomeVariable() on that sub-class, you will receive a runtime error:

class YourSubClass extends YourClass {
      private static function getTemperature() {
        return "-182 °C";
    }
}

print YourSubClass::getSomeVariable(); // Will cause an access error.

In the case above, it makes sense to update SomeClass to use self instead:

class YourClass
{
    private static function getTemperature() {
        return "3422 °C";
    }

    public static function getSomeVariable()
    {
        return self::getTemperature();
    }
}
Loading history...
68 12
        static::assertClassValueDefined(static::ON_INDEX_QUERY_VALIDATION_RULES_CLASS);
0 ignored issues
show
Bug introduced by
Since assertClassValueDefined() is declared private, calling it with static will lead to errors in possible sub-classes. You can either use self, or increase the visibility of assertClassValueDefined() to at least protected.

Let’s assume you have a class which uses late-static binding:

class YourClass
{
    private static function getTemperature() {
        return "3422 °C";
}

public static function getSomeVariable()
{
    return static::getTemperature();
}

}

The code above will run fine in your PHP runtime. However, if you now create a sub-class and call the getSomeVariable() on that sub-class, you will receive a runtime error:

class YourSubClass extends YourClass {
      private static function getTemperature() {
        return "-182 °C";
    }
}

print YourSubClass::getSomeVariable(); // Will cause an access error.

In the case above, it makes sense to update SomeClass to use self instead:

class YourClass
{
    private static function getTemperature() {
        return "3422 °C";
    }

    public static function getSomeVariable()
    {
        return self::getTemperature();
    }
}
Loading history...
69
70 12
        return static::defaultIndexHandler(
71 12
            $request->getQueryParams(),
72 12
            $request->getUri(),
73 12
            static::defaultCreateQueryParser($container, static::ON_INDEX_QUERY_VALIDATION_RULES_CLASS),
74 12
            static::defaultCreateParameterMapper($container, static::SCHEMA_CLASS),
75 12
            static::defaultCreateApi($container, static::API_CLASS),
76 12
            $container->get(SettingsProviderInterface::class),
77 12
            $container->get(JsonSchemasInterface::class),
78 12
            $container->get(EncoderInterface::class)
79
        );
80
    }
81
82
    /**
83
     * @inheritdoc
84
     */
85 1 View Code Duplication
    public static function create(
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
86
        array $routeParams,
87
        ContainerInterface $container,
88
        ServerRequestInterface $request
89
    ): ResponseInterface {
90 1
        static::assertClassValueDefined(static::API_CLASS);
0 ignored issues
show
Bug introduced by
Since assertClassValueDefined() is declared private, calling it with static will lead to errors in possible sub-classes. You can either use self, or increase the visibility of assertClassValueDefined() to at least protected.

Let’s assume you have a class which uses late-static binding:

class YourClass
{
    private static function getTemperature() {
        return "3422 °C";
}

public static function getSomeVariable()
{
    return static::getTemperature();
}

}

The code above will run fine in your PHP runtime. However, if you now create a sub-class and call the getSomeVariable() on that sub-class, you will receive a runtime error:

class YourSubClass extends YourClass {
      private static function getTemperature() {
        return "-182 °C";
    }
}

print YourSubClass::getSomeVariable(); // Will cause an access error.

In the case above, it makes sense to update SomeClass to use self instead:

class YourClass
{
    private static function getTemperature() {
        return "3422 °C";
    }

    public static function getSomeVariable()
    {
        return self::getTemperature();
    }
}
Loading history...
91 1
        static::assertClassValueDefined(static::SCHEMA_CLASS);
0 ignored issues
show
Bug introduced by
Since assertClassValueDefined() is declared private, calling it with static will lead to errors in possible sub-classes. You can either use self, or increase the visibility of assertClassValueDefined() to at least protected.

Let’s assume you have a class which uses late-static binding:

class YourClass
{
    private static function getTemperature() {
        return "3422 °C";
}

public static function getSomeVariable()
{
    return static::getTemperature();
}

}

The code above will run fine in your PHP runtime. However, if you now create a sub-class and call the getSomeVariable() on that sub-class, you will receive a runtime error:

class YourSubClass extends YourClass {
      private static function getTemperature() {
        return "-182 °C";
    }
}

print YourSubClass::getSomeVariable(); // Will cause an access error.

In the case above, it makes sense to update SomeClass to use self instead:

class YourClass
{
    private static function getTemperature() {
        return "3422 °C";
    }

    public static function getSomeVariable()
    {
        return self::getTemperature();
    }
}
Loading history...
92 1
        static::assertClassValueDefined(static::ON_CREATE_DATA_VALIDATION_RULES_CLASS);
0 ignored issues
show
Bug introduced by
Since assertClassValueDefined() is declared private, calling it with static will lead to errors in possible sub-classes. You can either use self, or increase the visibility of assertClassValueDefined() to at least protected.

Let’s assume you have a class which uses late-static binding:

class YourClass
{
    private static function getTemperature() {
        return "3422 °C";
}

public static function getSomeVariable()
{
    return static::getTemperature();
}

}

The code above will run fine in your PHP runtime. However, if you now create a sub-class and call the getSomeVariable() on that sub-class, you will receive a runtime error:

class YourSubClass extends YourClass {
      private static function getTemperature() {
        return "-182 °C";
    }
}

print YourSubClass::getSomeVariable(); // Will cause an access error.

In the case above, it makes sense to update SomeClass to use self instead:

class YourClass
{
    private static function getTemperature() {
        return "3422 °C";
    }

    public static function getSomeVariable()
    {
        return self::getTemperature();
    }
}
Loading history...
93
94 1
        $response = static::defaultCreateHandler(
95 1
            $request->getUri(),
96 1
            $request->getBody(),
97 1
            static::SCHEMA_CLASS,
98 1
            $container->get(ModelSchemaInfoInterface::class),
99 1
            static::defaultCreateDataParser($container, static::ON_CREATE_DATA_VALIDATION_RULES_CLASS),
100 1
            static::defaultCreateApi($container, static::API_CLASS),
101 1
            $container->get(SettingsProviderInterface::class),
102 1
            $container->get(JsonSchemasInterface::class),
103 1
            $container->get(EncoderInterface::class),
104 1
            $container->get(FactoryInterface::class),
105 1
            $container->get(FormatterFactoryInterface::class)
106
        );
107
108 1
        return $response;
109
    }
110
111
    /**
112
     * @inheritdoc
113
     */
114 1 View Code Duplication
    public static function read(
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
115
        array $routeParams,
116
        ContainerInterface $container,
117
        ServerRequestInterface $request
118
    ): ResponseInterface {
119 1
        static::assertClassValueDefined(static::API_CLASS);
0 ignored issues
show
Bug introduced by
Since assertClassValueDefined() is declared private, calling it with static will lead to errors in possible sub-classes. You can either use self, or increase the visibility of assertClassValueDefined() to at least protected.

Let’s assume you have a class which uses late-static binding:

class YourClass
{
    private static function getTemperature() {
        return "3422 °C";
}

public static function getSomeVariable()
{
    return static::getTemperature();
}

}

The code above will run fine in your PHP runtime. However, if you now create a sub-class and call the getSomeVariable() on that sub-class, you will receive a runtime error:

class YourSubClass extends YourClass {
      private static function getTemperature() {
        return "-182 °C";
    }
}

print YourSubClass::getSomeVariable(); // Will cause an access error.

In the case above, it makes sense to update SomeClass to use self instead:

class YourClass
{
    private static function getTemperature() {
        return "3422 °C";
    }

    public static function getSomeVariable()
    {
        return self::getTemperature();
    }
}
Loading history...
120 1
        static::assertClassValueDefined(static::SCHEMA_CLASS);
0 ignored issues
show
Bug introduced by
Since assertClassValueDefined() is declared private, calling it with static will lead to errors in possible sub-classes. You can either use self, or increase the visibility of assertClassValueDefined() to at least protected.

Let’s assume you have a class which uses late-static binding:

class YourClass
{
    private static function getTemperature() {
        return "3422 °C";
}

public static function getSomeVariable()
{
    return static::getTemperature();
}

}

The code above will run fine in your PHP runtime. However, if you now create a sub-class and call the getSomeVariable() on that sub-class, you will receive a runtime error:

class YourSubClass extends YourClass {
      private static function getTemperature() {
        return "-182 °C";
    }
}

print YourSubClass::getSomeVariable(); // Will cause an access error.

In the case above, it makes sense to update SomeClass to use self instead:

class YourClass
{
    private static function getTemperature() {
        return "3422 °C";
    }

    public static function getSomeVariable()
    {
        return self::getTemperature();
    }
}
Loading history...
121 1
        static::assertClassValueDefined(static::ON_READ_QUERY_VALIDATION_RULES_CLASS);
0 ignored issues
show
Bug introduced by
Since assertClassValueDefined() is declared private, calling it with static will lead to errors in possible sub-classes. You can either use self, or increase the visibility of assertClassValueDefined() to at least protected.

Let’s assume you have a class which uses late-static binding:

class YourClass
{
    private static function getTemperature() {
        return "3422 °C";
}

public static function getSomeVariable()
{
    return static::getTemperature();
}

}

The code above will run fine in your PHP runtime. However, if you now create a sub-class and call the getSomeVariable() on that sub-class, you will receive a runtime error:

class YourSubClass extends YourClass {
      private static function getTemperature() {
        return "-182 °C";
    }
}

print YourSubClass::getSomeVariable(); // Will cause an access error.

In the case above, it makes sense to update SomeClass to use self instead:

class YourClass
{
    private static function getTemperature() {
        return "3422 °C";
    }

    public static function getSomeVariable()
    {
        return self::getTemperature();
    }
}
Loading history...
122
123 1
        return static::defaultReadHandler(
124 1
            $routeParams[static::ROUTE_KEY_INDEX],
125 1
            $request->getQueryParams(),
126 1
            $request->getUri(),
127 1
            static::defaultCreateQueryParser($container, static::ON_READ_QUERY_VALIDATION_RULES_CLASS),
128 1
            static::defaultCreateParameterMapper($container, static::SCHEMA_CLASS),
129 1
            static::defaultCreateApi($container, static::API_CLASS),
130 1
            $container->get(SettingsProviderInterface::class),
131 1
            $container->get(JsonSchemasInterface::class),
132 1
            $container->get(EncoderInterface::class)
133
        );
134
    }
135
136
    /**
137
     * @inheritdoc
138
     */
139 5 View Code Duplication
    public static function update(
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
140
        array $routeParams,
141
        ContainerInterface $container,
142
        ServerRequestInterface $request
143
    ): ResponseInterface {
144 5
        static::assertClassValueDefined(static::API_CLASS);
0 ignored issues
show
Bug introduced by
Since assertClassValueDefined() is declared private, calling it with static will lead to errors in possible sub-classes. You can either use self, or increase the visibility of assertClassValueDefined() to at least protected.

Let’s assume you have a class which uses late-static binding:

class YourClass
{
    private static function getTemperature() {
        return "3422 °C";
}

public static function getSomeVariable()
{
    return static::getTemperature();
}

}

The code above will run fine in your PHP runtime. However, if you now create a sub-class and call the getSomeVariable() on that sub-class, you will receive a runtime error:

class YourSubClass extends YourClass {
      private static function getTemperature() {
        return "-182 °C";
    }
}

print YourSubClass::getSomeVariable(); // Will cause an access error.

In the case above, it makes sense to update SomeClass to use self instead:

class YourClass
{
    private static function getTemperature() {
        return "3422 °C";
    }

    public static function getSomeVariable()
    {
        return self::getTemperature();
    }
}
Loading history...
145 5
        static::assertClassValueDefined(static::SCHEMA_CLASS);
0 ignored issues
show
Bug introduced by
Since assertClassValueDefined() is declared private, calling it with static will lead to errors in possible sub-classes. You can either use self, or increase the visibility of assertClassValueDefined() to at least protected.

Let’s assume you have a class which uses late-static binding:

class YourClass
{
    private static function getTemperature() {
        return "3422 °C";
}

public static function getSomeVariable()
{
    return static::getTemperature();
}

}

The code above will run fine in your PHP runtime. However, if you now create a sub-class and call the getSomeVariable() on that sub-class, you will receive a runtime error:

class YourSubClass extends YourClass {
      private static function getTemperature() {
        return "-182 °C";
    }
}

print YourSubClass::getSomeVariable(); // Will cause an access error.

In the case above, it makes sense to update SomeClass to use self instead:

class YourClass
{
    private static function getTemperature() {
        return "3422 °C";
    }

    public static function getSomeVariable()
    {
        return self::getTemperature();
    }
}
Loading history...
146 5
        static::assertClassValueDefined(static::ON_UPDATE_DATA_VALIDATION_RULES_CLASS);
0 ignored issues
show
Bug introduced by
Since assertClassValueDefined() is declared private, calling it with static will lead to errors in possible sub-classes. You can either use self, or increase the visibility of assertClassValueDefined() to at least protected.

Let’s assume you have a class which uses late-static binding:

class YourClass
{
    private static function getTemperature() {
        return "3422 °C";
}

public static function getSomeVariable()
{
    return static::getTemperature();
}

}

The code above will run fine in your PHP runtime. However, if you now create a sub-class and call the getSomeVariable() on that sub-class, you will receive a runtime error:

class YourSubClass extends YourClass {
      private static function getTemperature() {
        return "-182 °C";
    }
}

print YourSubClass::getSomeVariable(); // Will cause an access error.

In the case above, it makes sense to update SomeClass to use self instead:

class YourClass
{
    private static function getTemperature() {
        return "3422 °C";
    }

    public static function getSomeVariable()
    {
        return self::getTemperature();
    }
}
Loading history...
147
148 5
        $response = static::defaultUpdateHandler(
149 5
            $routeParams[static::ROUTE_KEY_INDEX],
150 5
            $request->getUri(),
151 5
            $request->getBody(),
152 5
            static::SCHEMA_CLASS,
153 5
            $container->get(ModelSchemaInfoInterface::class),
154 5
            static::defaultCreateDataParser($container, static::ON_UPDATE_DATA_VALIDATION_RULES_CLASS),
155 5
            static::defaultCreateApi($container, static::API_CLASS),
156 5
            $container->get(SettingsProviderInterface::class),
157 5
            $container->get(JsonSchemasInterface::class),
158 5
            $container->get(EncoderInterface::class),
159 5
            $container->get(FactoryInterface::class),
160 5
            $container->get(FormatterFactoryInterface::class)
161
        );
162
163 2
        return $response;
164
    }
165
166
    /**
167
     * @inheritdoc
168
     */
169 1
    public static function delete(
170
        array $routeParams,
171
        ContainerInterface $container,
172
        ServerRequestInterface $request
173
    ): ResponseInterface {
174 1
        static::assertClassValueDefined(static::API_CLASS);
0 ignored issues
show
Bug introduced by
Since assertClassValueDefined() is declared private, calling it with static will lead to errors in possible sub-classes. You can either use self, or increase the visibility of assertClassValueDefined() to at least protected.

Let’s assume you have a class which uses late-static binding:

class YourClass
{
    private static function getTemperature() {
        return "3422 °C";
}

public static function getSomeVariable()
{
    return static::getTemperature();
}

}

The code above will run fine in your PHP runtime. However, if you now create a sub-class and call the getSomeVariable() on that sub-class, you will receive a runtime error:

class YourSubClass extends YourClass {
      private static function getTemperature() {
        return "-182 °C";
    }
}

print YourSubClass::getSomeVariable(); // Will cause an access error.

In the case above, it makes sense to update SomeClass to use self instead:

class YourClass
{
    private static function getTemperature() {
        return "3422 °C";
    }

    public static function getSomeVariable()
    {
        return self::getTemperature();
    }
}
Loading history...
175
176 1
        $response = static::defaultDeleteHandler(
177 1
            $routeParams[static::ROUTE_KEY_INDEX],
178 1
            $request->getUri(),
179 1
            static::defaultCreateQueryParser($container, static::ON_READ_QUERY_VALIDATION_RULES_CLASS),
180 1
            static::defaultCreateApi($container, static::API_CLASS),
181 1
            $container->get(SettingsProviderInterface::class),
182 1
            $container->get(JsonSchemasInterface::class),
183 1
            $container->get(EncoderInterface::class)
184
        );
185
186 1
        return $response;
187
    }
188
189
    /**
190
     * @param string                 $index
191
     * @param string                 $modelRelName
192
     * @param string                 $queryValRulesClass
193
     * @param ContainerInterface     $container
194
     * @param ServerRequestInterface $request
195
     *
196
     * @return ResponseInterface
197
     *
198
     * @throws ContainerExceptionInterface
199
     * @throws NotFoundExceptionInterface
200
     */
201 2 View Code Duplication
    protected static function readRelationship(
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
202
        string $index,
203
        string $modelRelName,
204
        string $queryValRulesClass,
205
        ContainerInterface $container,
206
        ServerRequestInterface $request
207
    ): ResponseInterface {
208 2
        static::assertClassValueDefined(static::API_CLASS);
0 ignored issues
show
Bug introduced by
Since assertClassValueDefined() is declared private, calling it with static will lead to errors in possible sub-classes. You can either use self, or increase the visibility of assertClassValueDefined() to at least protected.

Let’s assume you have a class which uses late-static binding:

class YourClass
{
    private static function getTemperature() {
        return "3422 °C";
}

public static function getSomeVariable()
{
    return static::getTemperature();
}

}

The code above will run fine in your PHP runtime. However, if you now create a sub-class and call the getSomeVariable() on that sub-class, you will receive a runtime error:

class YourSubClass extends YourClass {
      private static function getTemperature() {
        return "-182 °C";
    }
}

print YourSubClass::getSomeVariable(); // Will cause an access error.

In the case above, it makes sense to update SomeClass to use self instead:

class YourClass
{
    private static function getTemperature() {
        return "3422 °C";
    }

    public static function getSomeVariable()
    {
        return self::getTemperature();
    }
}
Loading history...
209 2
        static::assertClassValueDefined(static::SCHEMA_CLASS);
0 ignored issues
show
Bug introduced by
Since assertClassValueDefined() is declared private, calling it with static will lead to errors in possible sub-classes. You can either use self, or increase the visibility of assertClassValueDefined() to at least protected.

Let’s assume you have a class which uses late-static binding:

class YourClass
{
    private static function getTemperature() {
        return "3422 °C";
}

public static function getSomeVariable()
{
    return static::getTemperature();
}

}

The code above will run fine in your PHP runtime. However, if you now create a sub-class and call the getSomeVariable() on that sub-class, you will receive a runtime error:

class YourSubClass extends YourClass {
      private static function getTemperature() {
        return "-182 °C";
    }
}

print YourSubClass::getSomeVariable(); // Will cause an access error.

In the case above, it makes sense to update SomeClass to use self instead:

class YourClass
{
    private static function getTemperature() {
        return "3422 °C";
    }

    public static function getSomeVariable()
    {
        return self::getTemperature();
    }
}
Loading history...
210
211 2
        $api     = static::defaultCreateApi($container, static::API_CLASS);
212
        $handler = function () use ($api, $index, $modelRelName) {
213 2
            return $api->readRelationship($index, $modelRelName);
214 2
        };
215
216 2
        return static::defaultReadRelationshipWithClosureHandler(
217 2
            $index,
218 2
            $handler,
219 2
            $request->getQueryParams(),
220 2
            $request->getUri(),
221 2
            static::defaultCreateQueryParser($container, $queryValRulesClass),
222 2
            static::defaultCreateParameterMapper($container, static::SCHEMA_CLASS),
223 2
            $api,
224 2
            $container->get(SettingsProviderInterface::class),
225 2
            $container->get(JsonSchemasInterface::class),
226 2
            $container->get(EncoderInterface::class)
227
        );
228
    }
229
230
    /**
231
     * @param string                 $index
232
     * @param string                 $modelRelName
233
     * @param string                 $queryValRulesClass
234
     * @param ContainerInterface     $container
235
     * @param ServerRequestInterface $request
236
     *
237
     * @return ResponseInterface
238
     *
239
     * @throws ContainerExceptionInterface
240
     * @throws NotFoundExceptionInterface
241
     */
242 1 View Code Duplication
    protected static function readRelationshipIdentifiers(
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
243
        string $index,
244
        string $modelRelName,
245
        string $queryValRulesClass,
246
        ContainerInterface $container,
247
        ServerRequestInterface $request
248
    ): ResponseInterface {
249 1
        static::assertClassValueDefined(static::API_CLASS);
0 ignored issues
show
Bug introduced by
Since assertClassValueDefined() is declared private, calling it with static will lead to errors in possible sub-classes. You can either use self, or increase the visibility of assertClassValueDefined() to at least protected.

Let’s assume you have a class which uses late-static binding:

class YourClass
{
    private static function getTemperature() {
        return "3422 °C";
}

public static function getSomeVariable()
{
    return static::getTemperature();
}

}

The code above will run fine in your PHP runtime. However, if you now create a sub-class and call the getSomeVariable() on that sub-class, you will receive a runtime error:

class YourSubClass extends YourClass {
      private static function getTemperature() {
        return "-182 °C";
    }
}

print YourSubClass::getSomeVariable(); // Will cause an access error.

In the case above, it makes sense to update SomeClass to use self instead:

class YourClass
{
    private static function getTemperature() {
        return "3422 °C";
    }

    public static function getSomeVariable()
    {
        return self::getTemperature();
    }
}
Loading history...
250 1
        static::assertClassValueDefined(static::SCHEMA_CLASS);
0 ignored issues
show
Bug introduced by
Since assertClassValueDefined() is declared private, calling it with static will lead to errors in possible sub-classes. You can either use self, or increase the visibility of assertClassValueDefined() to at least protected.

Let’s assume you have a class which uses late-static binding:

class YourClass
{
    private static function getTemperature() {
        return "3422 °C";
}

public static function getSomeVariable()
{
    return static::getTemperature();
}

}

The code above will run fine in your PHP runtime. However, if you now create a sub-class and call the getSomeVariable() on that sub-class, you will receive a runtime error:

class YourSubClass extends YourClass {
      private static function getTemperature() {
        return "-182 °C";
    }
}

print YourSubClass::getSomeVariable(); // Will cause an access error.

In the case above, it makes sense to update SomeClass to use self instead:

class YourClass
{
    private static function getTemperature() {
        return "3422 °C";
    }

    public static function getSomeVariable()
    {
        return self::getTemperature();
    }
}
Loading history...
251
252 1
        $api     = static::defaultCreateApi($container, static::API_CLASS);
253
        $handler = function () use ($api, $index, $modelRelName) {
254 1
            return $api->readRelationship($index, $modelRelName);
255 1
        };
256
257 1
        return static::defaultReadRelationshipIdentifiersWithClosureHandler(
258 1
            $index,
259 1
            $handler,
260 1
            $request->getQueryParams(),
261 1
            $request->getUri(),
262 1
            static::defaultCreateQueryParser($container, $queryValRulesClass),
263 1
            static::defaultCreateParameterMapper($container, static::SCHEMA_CLASS),
264 1
            $api,
265 1
            $container->get(SettingsProviderInterface::class),
266 1
            $container->get(JsonSchemasInterface::class),
267 1
            $container->get(EncoderInterface::class)
268
        );
269
    }
270
271
    /**
272
     * @param string                 $parentIndex
273
     * @param string                 $jsonRelName
274
     * @param string                 $modelRelName
275
     * @param ContainerInterface     $container
276
     * @param ServerRequestInterface $request
277
     *
278
     * @return ResponseInterface
279
     */
280 1 View Code Duplication
    protected static function addInRelationship(
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
281
        string $parentIndex,
282
        string $jsonRelName,
283
        string $modelRelName,
284
        ContainerInterface $container,
285
        ServerRequestInterface $request
286
    ): ResponseInterface {
287 1
        static::assertClassValueDefined(static::API_CLASS);
0 ignored issues
show
Bug introduced by
Since assertClassValueDefined() is declared private, calling it with static will lead to errors in possible sub-classes. You can either use self, or increase the visibility of assertClassValueDefined() to at least protected.

Let’s assume you have a class which uses late-static binding:

class YourClass
{
    private static function getTemperature() {
        return "3422 °C";
}

public static function getSomeVariable()
{
    return static::getTemperature();
}

}

The code above will run fine in your PHP runtime. However, if you now create a sub-class and call the getSomeVariable() on that sub-class, you will receive a runtime error:

class YourSubClass extends YourClass {
      private static function getTemperature() {
        return "-182 °C";
    }
}

print YourSubClass::getSomeVariable(); // Will cause an access error.

In the case above, it makes sense to update SomeClass to use self instead:

class YourClass
{
    private static function getTemperature() {
        return "3422 °C";
    }

    public static function getSomeVariable()
    {
        return self::getTemperature();
    }
}
Loading history...
288 1
        static::assertClassValueDefined(static::SCHEMA_CLASS);
0 ignored issues
show
Bug introduced by
Since assertClassValueDefined() is declared private, calling it with static will lead to errors in possible sub-classes. You can either use self, or increase the visibility of assertClassValueDefined() to at least protected.

Let’s assume you have a class which uses late-static binding:

class YourClass
{
    private static function getTemperature() {
        return "3422 °C";
}

public static function getSomeVariable()
{
    return static::getTemperature();
}

}

The code above will run fine in your PHP runtime. However, if you now create a sub-class and call the getSomeVariable() on that sub-class, you will receive a runtime error:

class YourSubClass extends YourClass {
      private static function getTemperature() {
        return "-182 °C";
    }
}

print YourSubClass::getSomeVariable(); // Will cause an access error.

In the case above, it makes sense to update SomeClass to use self instead:

class YourClass
{
    private static function getTemperature() {
        return "3422 °C";
    }

    public static function getSomeVariable()
    {
        return self::getTemperature();
    }
}
Loading history...
289 1
        static::assertClassValueDefined(static::ON_READ_QUERY_VALIDATION_RULES_CLASS);
0 ignored issues
show
Bug introduced by
Since assertClassValueDefined() is declared private, calling it with static will lead to errors in possible sub-classes. You can either use self, or increase the visibility of assertClassValueDefined() to at least protected.

Let’s assume you have a class which uses late-static binding:

class YourClass
{
    private static function getTemperature() {
        return "3422 °C";
}

public static function getSomeVariable()
{
    return static::getTemperature();
}

}

The code above will run fine in your PHP runtime. However, if you now create a sub-class and call the getSomeVariable() on that sub-class, you will receive a runtime error:

class YourSubClass extends YourClass {
      private static function getTemperature() {
        return "-182 °C";
    }
}

print YourSubClass::getSomeVariable(); // Will cause an access error.

In the case above, it makes sense to update SomeClass to use self instead:

class YourClass
{
    private static function getTemperature() {
        return "3422 °C";
    }

    public static function getSomeVariable()
    {
        return self::getTemperature();
    }
}
Loading history...
290 1
        static::assertClassValueDefined(static::ON_UPDATE_DATA_VALIDATION_RULES_CLASS);
0 ignored issues
show
Bug introduced by
Since assertClassValueDefined() is declared private, calling it with static will lead to errors in possible sub-classes. You can either use self, or increase the visibility of assertClassValueDefined() to at least protected.

Let’s assume you have a class which uses late-static binding:

class YourClass
{
    private static function getTemperature() {
        return "3422 °C";
}

public static function getSomeVariable()
{
    return static::getTemperature();
}

}

The code above will run fine in your PHP runtime. However, if you now create a sub-class and call the getSomeVariable() on that sub-class, you will receive a runtime error:

class YourSubClass extends YourClass {
      private static function getTemperature() {
        return "-182 °C";
    }
}

print YourSubClass::getSomeVariable(); // Will cause an access error.

In the case above, it makes sense to update SomeClass to use self instead:

class YourClass
{
    private static function getTemperature() {
        return "3422 °C";
    }

    public static function getSomeVariable()
    {
        return self::getTemperature();
    }
}
Loading history...
291
292 1
        return static::defaultAddInRelationshipHandler(
293 1
            $parentIndex,
294 1
            $jsonRelName,
295 1
            $modelRelName,
296 1
            $request->getUri(),
297 1
            $request->getBody(),
298 1
            static::SCHEMA_CLASS,
299 1
            $container->get(ModelSchemaInfoInterface::class),
300 1
            static::defaultCreateQueryParser($container, static::ON_READ_QUERY_VALIDATION_RULES_CLASS),
301 1
            static::defaultCreateDataParser($container, static::ON_UPDATE_DATA_VALIDATION_RULES_CLASS),
302 1
            static::defaultCreateApi($container, static::API_CLASS),
303 1
            $container->get(SettingsProviderInterface::class),
304 1
            $container->get(JsonSchemasInterface::class),
305 1
            $container->get(EncoderInterface::class),
306 1
            $container->get(FactoryInterface::class),
307 1
            $container->get(FormatterFactoryInterface::class)
308
        );
309
    }
310
311
    /**
312
     * @param string                 $parentIndex
313
     * @param string                 $jsonRelName
314
     * @param string                 $modelRelName
315
     * @param ContainerInterface     $container
316
     * @param ServerRequestInterface $request
317
     *
318
     * @return ResponseInterface
319
     */
320 1 View Code Duplication
    protected static function deleteInRelationship(
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
321
        string $parentIndex,
322
        string $jsonRelName,
323
        string $modelRelName,
324
        ContainerInterface $container,
325
        ServerRequestInterface $request
326
    ): ResponseInterface {
327 1
        static::assertClassValueDefined(static::API_CLASS);
0 ignored issues
show
Bug introduced by
Since assertClassValueDefined() is declared private, calling it with static will lead to errors in possible sub-classes. You can either use self, or increase the visibility of assertClassValueDefined() to at least protected.

Let’s assume you have a class which uses late-static binding:

class YourClass
{
    private static function getTemperature() {
        return "3422 °C";
}

public static function getSomeVariable()
{
    return static::getTemperature();
}

}

The code above will run fine in your PHP runtime. However, if you now create a sub-class and call the getSomeVariable() on that sub-class, you will receive a runtime error:

class YourSubClass extends YourClass {
      private static function getTemperature() {
        return "-182 °C";
    }
}

print YourSubClass::getSomeVariable(); // Will cause an access error.

In the case above, it makes sense to update SomeClass to use self instead:

class YourClass
{
    private static function getTemperature() {
        return "3422 °C";
    }

    public static function getSomeVariable()
    {
        return self::getTemperature();
    }
}
Loading history...
328 1
        static::assertClassValueDefined(static::SCHEMA_CLASS);
0 ignored issues
show
Bug introduced by
Since assertClassValueDefined() is declared private, calling it with static will lead to errors in possible sub-classes. You can either use self, or increase the visibility of assertClassValueDefined() to at least protected.

Let’s assume you have a class which uses late-static binding:

class YourClass
{
    private static function getTemperature() {
        return "3422 °C";
}

public static function getSomeVariable()
{
    return static::getTemperature();
}

}

The code above will run fine in your PHP runtime. However, if you now create a sub-class and call the getSomeVariable() on that sub-class, you will receive a runtime error:

class YourSubClass extends YourClass {
      private static function getTemperature() {
        return "-182 °C";
    }
}

print YourSubClass::getSomeVariable(); // Will cause an access error.

In the case above, it makes sense to update SomeClass to use self instead:

class YourClass
{
    private static function getTemperature() {
        return "3422 °C";
    }

    public static function getSomeVariable()
    {
        return self::getTemperature();
    }
}
Loading history...
329 1
        static::assertClassValueDefined(static::ON_READ_QUERY_VALIDATION_RULES_CLASS);
0 ignored issues
show
Bug introduced by
Since assertClassValueDefined() is declared private, calling it with static will lead to errors in possible sub-classes. You can either use self, or increase the visibility of assertClassValueDefined() to at least protected.

Let’s assume you have a class which uses late-static binding:

class YourClass
{
    private static function getTemperature() {
        return "3422 °C";
}

public static function getSomeVariable()
{
    return static::getTemperature();
}

}

The code above will run fine in your PHP runtime. However, if you now create a sub-class and call the getSomeVariable() on that sub-class, you will receive a runtime error:

class YourSubClass extends YourClass {
      private static function getTemperature() {
        return "-182 °C";
    }
}

print YourSubClass::getSomeVariable(); // Will cause an access error.

In the case above, it makes sense to update SomeClass to use self instead:

class YourClass
{
    private static function getTemperature() {
        return "3422 °C";
    }

    public static function getSomeVariable()
    {
        return self::getTemperature();
    }
}
Loading history...
330 1
        static::assertClassValueDefined(static::ON_UPDATE_DATA_VALIDATION_RULES_CLASS);
0 ignored issues
show
Bug introduced by
Since assertClassValueDefined() is declared private, calling it with static will lead to errors in possible sub-classes. You can either use self, or increase the visibility of assertClassValueDefined() to at least protected.

Let’s assume you have a class which uses late-static binding:

class YourClass
{
    private static function getTemperature() {
        return "3422 °C";
}

public static function getSomeVariable()
{
    return static::getTemperature();
}

}

The code above will run fine in your PHP runtime. However, if you now create a sub-class and call the getSomeVariable() on that sub-class, you will receive a runtime error:

class YourSubClass extends YourClass {
      private static function getTemperature() {
        return "-182 °C";
    }
}

print YourSubClass::getSomeVariable(); // Will cause an access error.

In the case above, it makes sense to update SomeClass to use self instead:

class YourClass
{
    private static function getTemperature() {
        return "3422 °C";
    }

    public static function getSomeVariable()
    {
        return self::getTemperature();
    }
}
Loading history...
331
332 1
        return static::defaultDeleteInRelationshipHandler(
333 1
            $parentIndex,
334 1
            $jsonRelName,
335 1
            $modelRelName,
336 1
            $request->getUri(),
337 1
            $request->getBody(),
338 1
            static::SCHEMA_CLASS,
339 1
            $container->get(ModelSchemaInfoInterface::class),
340 1
            static::defaultCreateQueryParser($container, static::ON_READ_QUERY_VALIDATION_RULES_CLASS),
341 1
            static::defaultCreateDataParser($container, static::ON_UPDATE_DATA_VALIDATION_RULES_CLASS),
342 1
            static::defaultCreateApi($container, static::API_CLASS),
343 1
            $container->get(SettingsProviderInterface::class),
344 1
            $container->get(JsonSchemasInterface::class),
345 1
            $container->get(EncoderInterface::class),
346 1
            $container->get(FactoryInterface::class),
347 1
            $container->get(FormatterFactoryInterface::class)
348
        );
349
    }
350
351
    /**
352
     * @param string                 $parentIndex
353
     * @param string                 $jsonRelName
354
     * @param string                 $modelRelName
355
     * @param ContainerInterface     $container
356
     * @param ServerRequestInterface $request
357
     *
358
     * @return ResponseInterface
359
     */
360 1 View Code Duplication
    protected static function replaceInRelationship(
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
361
        string $parentIndex,
362
        string $jsonRelName,
363
        string $modelRelName,
364
        ContainerInterface $container,
365
        ServerRequestInterface $request
366
    ): ResponseInterface {
367 1
        static::assertClassValueDefined(static::API_CLASS);
0 ignored issues
show
Bug introduced by
Since assertClassValueDefined() is declared private, calling it with static will lead to errors in possible sub-classes. You can either use self, or increase the visibility of assertClassValueDefined() to at least protected.

Let’s assume you have a class which uses late-static binding:

class YourClass
{
    private static function getTemperature() {
        return "3422 °C";
}

public static function getSomeVariable()
{
    return static::getTemperature();
}

}

The code above will run fine in your PHP runtime. However, if you now create a sub-class and call the getSomeVariable() on that sub-class, you will receive a runtime error:

class YourSubClass extends YourClass {
      private static function getTemperature() {
        return "-182 °C";
    }
}

print YourSubClass::getSomeVariable(); // Will cause an access error.

In the case above, it makes sense to update SomeClass to use self instead:

class YourClass
{
    private static function getTemperature() {
        return "3422 °C";
    }

    public static function getSomeVariable()
    {
        return self::getTemperature();
    }
}
Loading history...
368 1
        static::assertClassValueDefined(static::SCHEMA_CLASS);
0 ignored issues
show
Bug introduced by
Since assertClassValueDefined() is declared private, calling it with static will lead to errors in possible sub-classes. You can either use self, or increase the visibility of assertClassValueDefined() to at least protected.

Let’s assume you have a class which uses late-static binding:

class YourClass
{
    private static function getTemperature() {
        return "3422 °C";
}

public static function getSomeVariable()
{
    return static::getTemperature();
}

}

The code above will run fine in your PHP runtime. However, if you now create a sub-class and call the getSomeVariable() on that sub-class, you will receive a runtime error:

class YourSubClass extends YourClass {
      private static function getTemperature() {
        return "-182 °C";
    }
}

print YourSubClass::getSomeVariable(); // Will cause an access error.

In the case above, it makes sense to update SomeClass to use self instead:

class YourClass
{
    private static function getTemperature() {
        return "3422 °C";
    }

    public static function getSomeVariable()
    {
        return self::getTemperature();
    }
}
Loading history...
369 1
        static::assertClassValueDefined(static::ON_READ_QUERY_VALIDATION_RULES_CLASS);
0 ignored issues
show
Bug introduced by
Since assertClassValueDefined() is declared private, calling it with static will lead to errors in possible sub-classes. You can either use self, or increase the visibility of assertClassValueDefined() to at least protected.

Let’s assume you have a class which uses late-static binding:

class YourClass
{
    private static function getTemperature() {
        return "3422 °C";
}

public static function getSomeVariable()
{
    return static::getTemperature();
}

}

The code above will run fine in your PHP runtime. However, if you now create a sub-class and call the getSomeVariable() on that sub-class, you will receive a runtime error:

class YourSubClass extends YourClass {
      private static function getTemperature() {
        return "-182 °C";
    }
}

print YourSubClass::getSomeVariable(); // Will cause an access error.

In the case above, it makes sense to update SomeClass to use self instead:

class YourClass
{
    private static function getTemperature() {
        return "3422 °C";
    }

    public static function getSomeVariable()
    {
        return self::getTemperature();
    }
}
Loading history...
370 1
        static::assertClassValueDefined(static::ON_UPDATE_DATA_VALIDATION_RULES_CLASS);
0 ignored issues
show
Bug introduced by
Since assertClassValueDefined() is declared private, calling it with static will lead to errors in possible sub-classes. You can either use self, or increase the visibility of assertClassValueDefined() to at least protected.

Let’s assume you have a class which uses late-static binding:

class YourClass
{
    private static function getTemperature() {
        return "3422 °C";
}

public static function getSomeVariable()
{
    return static::getTemperature();
}

}

The code above will run fine in your PHP runtime. However, if you now create a sub-class and call the getSomeVariable() on that sub-class, you will receive a runtime error:

class YourSubClass extends YourClass {
      private static function getTemperature() {
        return "-182 °C";
    }
}

print YourSubClass::getSomeVariable(); // Will cause an access error.

In the case above, it makes sense to update SomeClass to use self instead:

class YourClass
{
    private static function getTemperature() {
        return "3422 °C";
    }

    public static function getSomeVariable()
    {
        return self::getTemperature();
    }
}
Loading history...
371
372 1
        return static::defaultReplaceInRelationship(
373 1
            $parentIndex,
374 1
            $jsonRelName,
375 1
            $modelRelName,
376 1
            $request->getUri(),
377 1
            $request->getBody(),
378 1
            static::SCHEMA_CLASS,
379 1
            $container->get(ModelSchemaInfoInterface::class),
380 1
            static::defaultCreateQueryParser($container, static::ON_READ_QUERY_VALIDATION_RULES_CLASS),
381 1
            static::defaultCreateDataParser($container, static::ON_UPDATE_DATA_VALIDATION_RULES_CLASS),
382 1
            static::defaultCreateApi($container, static::API_CLASS),
383 1
            $container->get(SettingsProviderInterface::class),
384 1
            $container->get(JsonSchemasInterface::class),
385 1
            $container->get(EncoderInterface::class),
386 1
            $container->get(FactoryInterface::class),
387 1
            $container->get(FormatterFactoryInterface::class)
388
        );
389
    }
390
}
391