Passed
Pull Request — master (#16)
by Woody
02:09
created

ResponseDefinition   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 81
Duplicated Lines 0 %

Test Coverage

Coverage 55.56%

Importance

Changes 0
Metric Value
wmc 9
eloc 21
dl 0
loc 81
ccs 15
cts 27
cp 0.5556
rs 10
c 0
b 0
f 0

9 Methods

Rating   Name   Duplication   Size   Complexity  
A unserialize() 0 6 1
A hasHeadersSchema() 0 3 1
A __construct() 0 5 1
A getHeadersSchema() 0 3 1
A serialize() 0 6 1
A hasBodySchema() 0 3 1
A getContentTypes() 0 3 1
A getBodySchema() 0 3 1
A getStatusCode() 0 3 1
1
<?php
2
namespace ElevenLabs\Api\Definition;
3
4
class ResponseDefinition implements \Serializable, MessageDefinition
5
{
6
    /** @var int */
7
    private $statusCode;
8
9
    /** @var array */
10
    private $contentTypes;
11
12
    /** @var Parameters */
13
    private $parameters;
14
15
    /**
16
     * @param int $statusCode
17
     * @param array $allowedContentTypes
18
     * @param Parameters $parameters
19
     */
20 1
    public function __construct($statusCode, array $allowedContentTypes, Parameters $parameters)
21
    {
22 1
        $this->statusCode = $statusCode;
23 1
        $this->contentTypes = $allowedContentTypes;
24 1
        $this->parameters = $parameters;
25 1
    }
26
27
    /**
28
     * @return int
29
     */
30
    public function getStatusCode()
31
    {
32
        return $this->statusCode;
33
    }
34
35
    /**
36
     * @return bool
37
     */
38
    public function hasBodySchema()
39
    {
40
        return $this->parameters->hasBodySchema();
41
    }
42
43
    /**
44
     * @return \stdClass
45
     */
46
    public function getBodySchema()
47
    {
48
        return $this->parameters->getBodySchema();
49
    }
50
51
    public function hasHeadersSchema()
52
    {
53
        return $this->parameters->hasHeadersSchema();
54
    }
55
56
    public function getHeadersSchema()
57
    {
58
        return $this->parameters->getHeadersSchema();
59
    }
60
61
    /**
62
     * Supported response types
63
     * @return array
64
     */
65
    public function getContentTypes()
66
    {
67
        return $this->contentTypes;
68
    }
69
70 1
    public function serialize()
71
    {
72 1
        return serialize([
73 1
            'statusCode' => $this->statusCode,
74 1
            'contentTypes' => $this->contentTypes,
75 1
            'parameters' => $this->parameters
76
        ]);
77
    }
78
79 1
    public function unserialize($serialized)
80
    {
81 1
        $data = unserialize($serialized);
82 1
        $this->statusCode = $data['statusCode'];
83 1
        $this->contentTypes = $data['contentTypes'];
84 1
        $this->parameters = $data['parameters'];
85 1
    }
86
}
87