Completed
Push — master ( cc2b64...3127a8 )
by
unknown
28:00 queued 12:57
created

CreatePricelist   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
c 1
b 0
f 0
dl 0
loc 45
rs 10
wmc 11

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getUri() 0 3 1
A __construct() 0 3 1
A getMethod() 0 3 1
A getExtraHeaders() 0 3 1
A transformResponseBody() 0 7 5
A getBody() 0 6 2
1
<?php
2
3
namespace Starweb\Api\Generated\Endpoint;
4
5
class CreatePricelist extends \Jane\OpenApiRuntime\Client\BaseEndpoint implements \Jane\OpenApiRuntime\Client\Psr7HttplugEndpoint
6
{
7
    /**
8
     * Create a pricelist. Retrieves the created `Pricelist` object
9
     *
10
     * @param mixed $requestBody 
11
     */
12
    public function __construct(mixed $requestBody)
0 ignored issues
show
Bug introduced by
The type Starweb\Api\Generated\Endpoint\mixed was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
13
    {
14
        $this->body = $requestBody;
15
    }
16
    use \Jane\OpenApiRuntime\Client\Psr7HttplugEndpointTrait;
17
    public function getMethod() : string
18
    {
19
        return 'POST';
20
    }
21
    public function getUri() : string
22
    {
23
        return '/pricelists';
24
    }
25
    public function getBody(\Symfony\Component\Serializer\SerializerInterface $serializer, \Http\Message\StreamFactory $streamFactory = null) : array
26
    {
27
        if (isset($this->body)) {
28
            return array(array('Content-Type' => array('application/json')), json_encode($this->body));
29
        }
30
        return array(array(), null);
31
    }
32
    public function getExtraHeaders() : array
33
    {
34
        return array('Accept' => array('application/json'));
35
    }
36
    /**
37
     * {@inheritdoc}
38
     *
39
     * @throws \Starweb\Api\Generated\Exception\CreatePricelistBadRequestException
40
     *
41
     * @return null|\Starweb\Api\Generated\Model\PricelistModelItem
42
     */
43
    protected function transformResponseBody(string $body, int $status, \Symfony\Component\Serializer\SerializerInterface $serializer, ?string $contentType = null)
44
    {
45
        if (201 === $status && 'application/json' === $contentType) {
46
            return $serializer->deserialize($body, 'Starweb\\Api\\Generated\\Model\\PricelistModelItem', 'json');
47
        }
48
        if (400 === $status && 'application/json' === $contentType) {
49
            throw new \Starweb\Api\Generated\Exception\CreatePricelistBadRequestException($serializer->deserialize($body, 'Starweb\\Api\\Generated\\Model\\ErrorModel', 'json'));
0 ignored issues
show
Bug introduced by
It seems like $serializer->deserialize...el\ErrorModel', 'json') can also be of type array; however, parameter $errorModel of Starweb\Api\Generated\Ex...xception::__construct() does only seem to accept Starweb\Api\Generated\Model\ErrorModel, maybe add an additional type check? ( Ignorable by Annotation )

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

49
            throw new \Starweb\Api\Generated\Exception\CreatePricelistBadRequestException(/** @scrutinizer ignore-type */ $serializer->deserialize($body, 'Starweb\\Api\\Generated\\Model\\ErrorModel', 'json'));
Loading history...
50
        }
51
    }
52
}