Parameter   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 97
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 8
eloc 27
dl 0
loc 97
ccs 35
cts 35
cp 1
rs 10
c 0
b 0
f 0

8 Methods

Rating   Name   Duplication   Size   Complexity  
A serialize() 0 7 1
A isRequired() 0 3 1
A getSchema() 0 3 1
A getName() 0 3 1
A hasSchema() 0 3 1
A unserialize() 0 7 1
A getLocation() 0 3 1
A __construct() 0 6 1
1
<?php
2
namespace ElevenLabs\Api\Definition;
3
4
class Parameter implements \Serializable
5
{
6
    const LOCATIONS = ['path', 'header', 'query', 'body', 'formData'];
7
    const BODY_LOCATIONS = ['formData', 'body'];
8
    const BODY_LOCATIONS_TYPES = ['formData' => 'application/x-www-form-urlencoded', 'body'  => 'application/json'];
9
10
    /**
11
     * Location of the parameter in the request
12
     *
13
     * @var string
14
     */
15
    private $location;
16
17
    /**
18
     * @var string
19
     */
20
    private $name;
21
22
    /**
23
     * Indicate if the parameter should be present
24
     *
25
     * @var bool
26 13
     */
27
    private $required;
28
29
    /**
30
     * A JSON Schema object
31
     *
32 13
     * @var \stdClass
33 1
     */
34 1
    private $schema;
35 1
36 1
    public function __construct($location, $name, $required, \stdClass $schema = null)
37 1
    {
38
        $this->location = $location;
39
        $this->name = $name;
40
        $this->required = $required;
41
        $this->schema = $schema;
42 12
    }
43 12
44 12
    /**
45 12
     * @return string
46 12
     */
47
    public function getLocation()
48 5
    {
49
        return $this->location;
50 5
    }
51
52
    /**
53 11
     * @return string
54
     */
55 11
    public function getName()
56
    {
57
        return $this->name;
58 2
    }
59
60 2
    /**
61
     * @return boolean
62
     */
63 4
    public function isRequired()
64
    {
65 4
        return $this->required;
66
    }
67
68 2
    /**
69
     * @return \stdClass
70 2
     */
71
    public function getSchema()
72
    {
73 1
        return $this->schema;
74
    }
75 1
76 1
    /**
77 1
     * @return bool
78 1
     */
79 1
    public function hasSchema()
80
    {
81
        return $this->schema !== null;
82
    }
83 1
84
    public function serialize()
85 1
    {
86 1
        return serialize([
87 1
            'location' => $this->location,
88 1
            'name' => $this->name,
89 1
            'required' => $this->required,
90 1
            'schema' => $this->schema
91
        ]);
92
    }
93
94
    public function unserialize($serialized)
95
    {
96
        $data = unserialize($serialized);
97
        $this->location = $data['location'];
98
        $this->name = $data['name'];
99
        $this->required  = $data['required'];
100
        $this->schema  = $data['schema'];
101
    }
102
}
103