CertificateRequest::delete()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 6
ccs 4
cts 4
cp 1
crap 1
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace CCT\Kong\Http\Request;
6
7
use CCT\Kong\Config;
8
use CCT\Kong\Http\Request;
9
use CCT\Kong\Http\Response;
10
use CCT\Kong\Http\ResponseInterface;
11
use CCT\Kong\Model\Certificate;
12
13
class CertificateRequest extends Request
14
{
15
    /**
16
     * {@inheritdoc}
17
     */
18 11
    protected function setUp()
19
    {
20 11
        if (!$this->config->has(Config::URI_PREFIX)) {
21 11
            $this->config->set(Config::URI_PREFIX, '/certificates/');
22
        }
23 11
    }
24
25 1
    public function list(): ResponseInterface
26
    {
27 1
        $this->setSerializationContextFor(['read']);
28
29 1
        return parent::requestGet($this->getUri(), null);
0 ignored issues
show
Bug Best Practice introduced by
The expression return parent::requestGet($this->getUri(), null) could return the type Symfony\Component\HttpFoundation\Response which is incompatible with the type-hinted return CCT\Kong\Http\ResponseInterface. Consider adding an additional type-check to rule them out.
Loading history...
30
    }
31
32 2
    public function create(Certificate $certificate): ResponseInterface
33
    {
34 2
        $this->setSerializationContextFor(['create']);
35
36 2
        return parent::requestPost($this->getUri(), $certificate);
0 ignored issues
show
Bug Best Practice introduced by
The expression return parent::requestPo...getUri(), $certificate) could return the type Symfony\Component\HttpFoundation\Response which is incompatible with the type-hinted return CCT\Kong\Http\ResponseInterface. Consider adding an additional type-check to rule them out.
Loading history...
37
    }
38
39 5
    public function retrieve(string $sniOrCertificateId): ResponseInterface
40
    {
41 5
        $this->setSerializationContextFor(['read']);
42
43 5
        return parent::requestGet($this->appendToUri($sniOrCertificateId));
0 ignored issues
show
Bug Best Practice introduced by
The expression return parent::requestGe...i($sniOrCertificateId)) could return the type Symfony\Component\HttpFoundation\Response which is incompatible with the type-hinted return CCT\Kong\Http\ResponseInterface. Consider adding an additional type-check to rule them out.
Loading history...
44
    }
45
46 1
    public function update(Certificate $certificate): Response
47
    {
48 1
        $this->validateObjectId($certificate);
49 1
        $this->setSerializationContextFor(['update']);
50
51 1
        return parent::requestPatch($this->appendToUri($certificate->getId()), $certificate);
0 ignored issues
show
Bug Best Practice introduced by
The expression return parent::requestPa...getId()), $certificate) returns the type Symfony\Component\HttpFo...\Http\ResponseInterface which includes types incompatible with the type-hinted return CCT\Kong\Http\Response.
Loading history...
52
    }
53
54 2
    public function updateOrCreate(Certificate $certificate): Response
55
    {
56 2
        $this->setSerializationContextFor(['update', 'create']);
57
58 2
        return parent::requestPut($this->getUri(), $certificate);
0 ignored issues
show
Bug Best Practice introduced by
The expression return parent::requestPu...getUri(), $certificate) returns the type Symfony\Component\HttpFo...\Http\ResponseInterface which includes types incompatible with the type-hinted return CCT\Kong\Http\Response.
Loading history...
59
    }
60
61 2
    public function delete(Certificate $certificate)
62
    {
63 2
        $this->validateObjectId($certificate);
64 1
        $this->setSerializationContextFor(['delete']);
65
66 1
        return parent::requestDelete($this->appendToUri($certificate->getId()));
67
    }
68
}
69