Completed
Push — develop ( 3822de...d029a9 )
by Neomerx
06:40
created

JsonApiBaseController::replaceInRelationship()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 28

Duplication

Lines 28
Ratio 100 %

Code Coverage

Tests 19
CRAP Score 1

Importance

Changes 0
Metric Value
dl 28
loc 28
ccs 19
cts 19
cp 1
rs 9.472
c 0
b 0
f 0
cc 1
nc 1
nop 5
crap 1
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\Flute\Contracts\Encoder\EncoderInterface;
22
use Limoncello\Flute\Contracts\FactoryInterface;
23
use Limoncello\Flute\Contracts\Http\JsonApiControllerInterface;
24
use Limoncello\Flute\Contracts\Schema\JsonSchemasInterface;
25
use Limoncello\Flute\Http\Traits\DefaultControllerMethodsTrait;
26
use Psr\Container\ContainerExceptionInterface;
27
use Psr\Container\ContainerInterface;
28
use Psr\Container\NotFoundExceptionInterface;
29
use Psr\Http\Message\ResponseInterface;
30
use Psr\Http\Message\ServerRequestInterface;
31
32
/**
33
 * @package Limoncello\Flute
34
 */
35
abstract class JsonApiBaseController implements JsonApiControllerInterface
36
{
37
    use DefaultControllerMethodsTrait;
38
39
    /** API class name */
40
    const API_CLASS = null;
41
42
    /** JSON API Schema class name */
43
    const SCHEMA_CLASS = null;
44
45
    /** JSON API query validation rules class */
46
    const ON_INDEX_QUERY_VALIDATION_RULES_CLASS = null;
47
48
    /** JSON API query validation rules class */
49
    const ON_READ_QUERY_VALIDATION_RULES_CLASS = null;
50
51
    /** JSON API data validation rules class */
52
    const ON_CREATE_DATA_VALIDATION_RULES_CLASS = null;
53
54
    /** JSON API data validation rules class */
55
    const ON_UPDATE_DATA_VALIDATION_RULES_CLASS = null;
56
57
    /**
58
     * @inheritdoc
59
     */
60 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...
61
        array $routeParams,
62
        ContainerInterface $container,
63
        ServerRequestInterface $request
64
    ): ResponseInterface {
65 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...
66 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...
67 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...
68
69 12
        return static::defaultIndexHandler(
70 12
            $request->getQueryParams(),
71 12
            $request->getUri(),
72 12
            static::defaultCreateQueryParser($container, static::ON_INDEX_QUERY_VALIDATION_RULES_CLASS),
73 12
            static::defaultCreateParameterMapper($container, static::SCHEMA_CLASS),
74 12
            static::defaultCreateApi($container, static::API_CLASS),
75 12
            $container->get(EncoderInterface::class)
76
        );
77
    }
78
79
    /**
80
     * @inheritdoc
81
     */
82 2 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...
83
        array $routeParams,
84
        ContainerInterface $container,
85
        ServerRequestInterface $request
86
    ): ResponseInterface {
87 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...
88 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...
89 2
        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...
90
91 2
        $response = static::defaultCreateHandler(
92 2
            $request->getUri(),
93 2
            $request->getBody(),
94 2
            static::SCHEMA_CLASS,
95 2
            $container->get(ModelSchemaInfoInterface::class),
96 2
            static::defaultCreateDataParser($container, static::ON_CREATE_DATA_VALIDATION_RULES_CLASS),
97 2
            static::defaultCreateApi($container, static::API_CLASS),
98 2
            $container->get(JsonSchemasInterface::class),
99 2
            $container->get(EncoderInterface::class),
100 2
            $container->get(FactoryInterface::class),
101 2
            $container->get(FormatterFactoryInterface::class)
102
        );
103
104 1
        return $response;
105
    }
106
107
    /**
108
     * @inheritdoc
109
     */
110 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...
111
        array $routeParams,
112
        ContainerInterface $container,
113
        ServerRequestInterface $request
114
    ): ResponseInterface {
115 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...
116 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...
117 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...
118
119 1
        return static::defaultReadHandler(
120 1
            $routeParams[static::ROUTE_KEY_INDEX],
121 1
            $request->getQueryParams(),
122 1
            $request->getUri(),
123 1
            static::defaultCreateQueryParser($container, static::ON_READ_QUERY_VALIDATION_RULES_CLASS),
124 1
            static::defaultCreateParameterMapper($container, static::SCHEMA_CLASS),
125 1
            static::defaultCreateApi($container, static::API_CLASS),
126 1
            $container->get(EncoderInterface::class)
127
        );
128
    }
129
130
    /**
131
     * @inheritdoc
132
     */
133 6 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...
134
        array $routeParams,
135
        ContainerInterface $container,
136
        ServerRequestInterface $request
137
    ): ResponseInterface {
138 6
        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...
139 6
        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...
140 6
        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...
141
142 6
        $response = static::defaultUpdateHandler(
143 6
            $routeParams[static::ROUTE_KEY_INDEX],
144 6
            $request->getUri(),
145 6
            $request->getBody(),
146 6
            static::SCHEMA_CLASS,
147 6
            $container->get(ModelSchemaInfoInterface::class),
148 6
            static::defaultCreateDataParser($container, static::ON_UPDATE_DATA_VALIDATION_RULES_CLASS),
149 6
            static::defaultCreateApi($container, static::API_CLASS),
150 6
            $container->get(EncoderInterface::class),
151 6
            $container->get(FactoryInterface::class),
152 6
            $container->get(FormatterFactoryInterface::class)
153
        );
154
155 2
        return $response;
156
    }
157
158
    /**
159
     * @inheritdoc
160
     */
161 1
    public static function delete(
162
        array $routeParams,
163
        ContainerInterface $container,
164
        ServerRequestInterface $request
165
    ): ResponseInterface {
166 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...
167
168 1
        $response = static::defaultDeleteHandler(
169 1
            $routeParams[static::ROUTE_KEY_INDEX],
170 1
            $request->getUri(),
171 1
            static::defaultCreateQueryParser($container, static::ON_READ_QUERY_VALIDATION_RULES_CLASS),
172 1
            static::defaultCreateApi($container, static::API_CLASS),
173 1
            $container->get(EncoderInterface::class)
174
        );
175
176 1
        return $response;
177
    }
178
179
    /**
180
     * @param string                 $index
181
     * @param string                 $modelRelName
182
     * @param string                 $queryValRulesClass
183
     * @param ContainerInterface     $container
184
     * @param ServerRequestInterface $request
185
     *
186
     * @return ResponseInterface
187
     *
188
     * @throws ContainerExceptionInterface
189
     * @throws NotFoundExceptionInterface
190
     */
191 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...
192
        string $index,
193
        string $modelRelName,
194
        string $queryValRulesClass,
195
        ContainerInterface $container,
196
        ServerRequestInterface $request
197
    ): ResponseInterface {
198 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...
199 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...
200
201 2
        $api     = static::defaultCreateApi($container, static::API_CLASS);
202
        $handler = function () use ($api, $index, $modelRelName) {
203 2
            return $api->readRelationship($index, $modelRelName);
204 2
        };
205
206 2
        return static::defaultReadRelationshipWithClosureHandler(
207 2
            $index,
208 2
            $handler,
209 2
            $request->getQueryParams(),
210 2
            $request->getUri(),
211 2
            static::defaultCreateQueryParser($container, $queryValRulesClass),
212 2
            static::defaultCreateParameterMapper($container, static::SCHEMA_CLASS),
213 2
            $api,
214 2
            $container->get(EncoderInterface::class)
215
        );
216
    }
217
218
    /**
219
     * @param string                 $index
220
     * @param string                 $modelRelName
221
     * @param string                 $queryValRulesClass
222
     * @param ContainerInterface     $container
223
     * @param ServerRequestInterface $request
224
     *
225
     * @return ResponseInterface
226
     *
227
     * @throws ContainerExceptionInterface
228
     * @throws NotFoundExceptionInterface
229
     */
230 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...
231
        string $index,
232
        string $modelRelName,
233
        string $queryValRulesClass,
234
        ContainerInterface $container,
235
        ServerRequestInterface $request
236
    ): ResponseInterface {
237 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...
238 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...
239
240 1
        $api     = static::defaultCreateApi($container, static::API_CLASS);
241
        $handler = function () use ($api, $index, $modelRelName) {
242 1
            return $api->readRelationship($index, $modelRelName);
243 1
        };
244
245 1
        return static::defaultReadRelationshipIdentifiersWithClosureHandler(
246 1
            $index,
247 1
            $handler,
248 1
            $request->getQueryParams(),
249 1
            $request->getUri(),
250 1
            static::defaultCreateQueryParser($container, $queryValRulesClass),
251 1
            static::defaultCreateParameterMapper($container, static::SCHEMA_CLASS),
252 1
            $api,
253 1
            $container->get(EncoderInterface::class)
254
        );
255
    }
256
257
    /**
258
     * @param string                 $parentIndex
259
     * @param string                 $jsonRelName
260
     * @param string                 $modelRelName
261
     * @param ContainerInterface     $container
262
     * @param ServerRequestInterface $request
263
     *
264
     * @return ResponseInterface
265
     */
266 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...
267
        string $parentIndex,
268
        string $jsonRelName,
269
        string $modelRelName,
270
        ContainerInterface $container,
271
        ServerRequestInterface $request
272
    ): ResponseInterface {
273 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...
274 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...
275 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...
276 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...
277
278 1
        return static::defaultAddInRelationshipHandler(
279 1
            $parentIndex,
280 1
            $jsonRelName,
281 1
            $modelRelName,
282 1
            $request->getUri(),
283 1
            $request->getBody(),
284 1
            static::SCHEMA_CLASS,
285 1
            $container->get(ModelSchemaInfoInterface::class),
286 1
            static::defaultCreateQueryParser($container, static::ON_READ_QUERY_VALIDATION_RULES_CLASS),
287 1
            static::defaultCreateDataParser($container, static::ON_UPDATE_DATA_VALIDATION_RULES_CLASS),
288 1
            static::defaultCreateApi($container, static::API_CLASS),
289 1
            $container->get(EncoderInterface::class),
290 1
            $container->get(FactoryInterface::class),
291 1
            $container->get(FormatterFactoryInterface::class)
292
        );
293
    }
294
295
    /**
296
     * @param string                 $parentIndex
297
     * @param string                 $jsonRelName
298
     * @param string                 $modelRelName
299
     * @param ContainerInterface     $container
300
     * @param ServerRequestInterface $request
301
     *
302
     * @return ResponseInterface
303
     */
304 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...
305
        string $parentIndex,
306
        string $jsonRelName,
307
        string $modelRelName,
308
        ContainerInterface $container,
309
        ServerRequestInterface $request
310
    ): ResponseInterface {
311 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...
312 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...
313 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...
314 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...
315
316 1
        return static::defaultDeleteInRelationshipHandler(
317 1
            $parentIndex,
318 1
            $jsonRelName,
319 1
            $modelRelName,
320 1
            $request->getUri(),
321 1
            $request->getBody(),
322 1
            static::SCHEMA_CLASS,
323 1
            $container->get(ModelSchemaInfoInterface::class),
324 1
            static::defaultCreateQueryParser($container, static::ON_READ_QUERY_VALIDATION_RULES_CLASS),
325 1
            static::defaultCreateDataParser($container, static::ON_UPDATE_DATA_VALIDATION_RULES_CLASS),
326 1
            static::defaultCreateApi($container, static::API_CLASS),
327 1
            $container->get(EncoderInterface::class),
328 1
            $container->get(FactoryInterface::class),
329 1
            $container->get(FormatterFactoryInterface::class)
330
        );
331
    }
332
333
    /**
334
     * @param string                 $parentIndex
335
     * @param string                 $jsonRelName
336
     * @param string                 $modelRelName
337
     * @param ContainerInterface     $container
338
     * @param ServerRequestInterface $request
339
     *
340
     * @return ResponseInterface
341
     */
342 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...
343
        string $parentIndex,
344
        string $jsonRelName,
345
        string $modelRelName,
346
        ContainerInterface $container,
347
        ServerRequestInterface $request
348
    ): ResponseInterface {
349 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...
350 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...
351 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...
352 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...
353
354 1
        return static::defaultReplaceInRelationship(
355 1
            $parentIndex,
356 1
            $jsonRelName,
357 1
            $modelRelName,
358 1
            $request->getUri(),
359 1
            $request->getBody(),
360 1
            static::SCHEMA_CLASS,
361 1
            $container->get(ModelSchemaInfoInterface::class),
362 1
            static::defaultCreateQueryParser($container, static::ON_READ_QUERY_VALIDATION_RULES_CLASS),
363 1
            static::defaultCreateDataParser($container, static::ON_UPDATE_DATA_VALIDATION_RULES_CLASS),
364 1
            static::defaultCreateApi($container, static::API_CLASS),
365 1
            $container->get(EncoderInterface::class),
366 1
            $container->get(FactoryInterface::class),
367 1
            $container->get(FormatterFactoryInterface::class)
368
        );
369
    }
370
}
371