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

PatchPricelist::getBody()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 3
c 1
b 0
f 0
nc 2
nop 2
dl 0
loc 6
rs 10
1
<?php
2
3
namespace Starweb\Api\Generated\Endpoint;
4
5
class PatchPricelist extends \Jane\OpenApiRuntime\Client\BaseEndpoint implements \Jane\OpenApiRuntime\Client\Psr7HttplugEndpoint
6
{
7
    protected $pricelistId;
8
    /**
9
     * Update a pricelist. Retrieves the updated `Pricelist` object
10
     *
11
     * @param int $pricelistId The pricelist id
12
     * @param mixed $requestBody 
13
     */
14
    public function __construct(int $pricelistId, 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...
15
    {
16
        $this->pricelistId = $pricelistId;
17
        $this->body = $requestBody;
18
    }
19
    use \Jane\OpenApiRuntime\Client\Psr7HttplugEndpointTrait;
20
    public function getMethod() : string
21
    {
22
        return 'PATCH';
23
    }
24
    public function getUri() : string
25
    {
26
        return str_replace(array('{pricelistId}'), array($this->pricelistId), '/pricelists/{pricelistId}');
27
    }
28
    public function getBody(\Symfony\Component\Serializer\SerializerInterface $serializer, \Http\Message\StreamFactory $streamFactory = null) : array
29
    {
30
        if (isset($this->body)) {
31
            return array(array('Content-Type' => array('application/json')), json_encode($this->body));
32
        }
33
        return array(array(), null);
34
    }
35
    public function getExtraHeaders() : array
36
    {
37
        return array('Accept' => array('application/json'));
38
    }
39
    /**
40
     * {@inheritdoc}
41
     *
42
     * @throws \Starweb\Api\Generated\Exception\PatchPricelistBadRequestException
43
     * @throws \Starweb\Api\Generated\Exception\PatchPricelistNotFoundException
44
     *
45
     * @return null|\Starweb\Api\Generated\Model\PricelistModelItem
46
     */
47
    protected function transformResponseBody(string $body, int $status, \Symfony\Component\Serializer\SerializerInterface $serializer, ?string $contentType = null)
48
    {
49
        if (200 === $status && 'application/json' === $contentType) {
50
            return $serializer->deserialize($body, 'Starweb\\Api\\Generated\\Model\\PricelistModelItem', 'json');
51
        }
52
        if (400 === $status && 'application/json' === $contentType) {
53
            throw new \Starweb\Api\Generated\Exception\PatchPricelistBadRequestException($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

53
            throw new \Starweb\Api\Generated\Exception\PatchPricelistBadRequestException(/** @scrutinizer ignore-type */ $serializer->deserialize($body, 'Starweb\\Api\\Generated\\Model\\ErrorModel', 'json'));
Loading history...
54
        }
55
        if (404 === $status && 'application/json' === $contentType) {
56
            throw new \Starweb\Api\Generated\Exception\PatchPricelistNotFoundException($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

56
            throw new \Starweb\Api\Generated\Exception\PatchPricelistNotFoundException(/** @scrutinizer ignore-type */ $serializer->deserialize($body, 'Starweb\\Api\\Generated\\Model\\ErrorModel', 'json'));
Loading history...
57
        }
58
    }
59
}