Passed
Pull Request — master (#32)
by
unknown
18:56
created

DeleteProductUnit::getUri()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
cc 1
eloc 1
c 1
b 1
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
namespace Starweb\Api\Generated\Endpoint;
4
5
class DeleteProductUnit extends \Jane\OpenApiRuntime\Client\BaseEndpoint implements \Jane\OpenApiRuntime\Client\Psr7Endpoint
6
{
7
    protected $unitId;
8
    /**
9
     * Deletes the `ProductUnit` object.
10
     *
11
     * @param int $unitId The units id
12
     */
13
    public function __construct(int $unitId)
14
    {
15
        $this->unitId = $unitId;
16
    }
17
    use \Jane\OpenApiRuntime\Client\Psr7EndpointTrait;
18
    public function getMethod() : string
19
    {
20
        return 'DELETE';
21
    }
22
    public function getUri() : string
23
    {
24
        return str_replace(array('{unitId}'), array($this->unitId), '/product-units/{unitId}');
25
    }
26
    public function getBody(\Symfony\Component\Serializer\SerializerInterface $serializer, $streamFactory = null) : array
27
    {
28
        return array(array(), null);
29
    }
30
    public function getExtraHeaders() : array
31
    {
32
        return array('Accept' => array('application/json'));
33
    }
34
    /**
35
     * {@inheritdoc}
36
     *
37
     * @throws \Starweb\Api\Generated\Exception\DeleteProductUnitNotFoundException
38
     *
39
     * @return null
40
     */
41
    protected function transformResponseBody(string $body, int $status, \Symfony\Component\Serializer\SerializerInterface $serializer, ?string $contentType = null)
42
    {
43
        if (204 === $status) {
44
            return null;
45
        }
46
        if (404 === $status && mb_strpos($contentType, 'application/json') !== false) {
0 ignored issues
show
Bug introduced by
It seems like $contentType can also be of type null; however, parameter $haystack of mb_strpos() does only seem to accept string, 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

46
        if (404 === $status && mb_strpos(/** @scrutinizer ignore-type */ $contentType, 'application/json') !== false) {
Loading history...
47
            throw new \Starweb\Api\Generated\Exception\DeleteProductUnitNotFoundException($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

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