Passed
Pull Request — master (#34)
by Anatoly
02:04
created

ServerVariable::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
nc 1
nop 2
crap 1
1
<?php declare(strict_types=1);
2
3
/**
4
 * It's free open-source software released under the MIT License.
5
 *
6
 * @author Anatoly Fenric <[email protected]>
7
 * @copyright Copyright (c) 2018, Anatoly Fenric
8
 * @license https://github.com/sunrise-php/http-router/blob/master/LICENSE
9
 * @link https://github.com/sunrise-php/http-router
10
 */
11
12
namespace Sunrise\Http\Router\OpenApi;
13
14
/**
15
 * OAS Server Variable Object
16
 *
17
 * @link https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#server-variable-object
18
 */
19
class ServerVariable extends AbstractObject
20
{
21
22
    /**
23
     * @var string
24
     */
25
    private $name;
26
27
    /**
28
     * @var string[]
29
     *
30
     * @link https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#user-content-servervariableenum
31
     */
32
    protected $enum;
33
34
    /**
35
     * @var string
36
     *
37
     * @link https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#user-content-servervariabledefault
38
     */
39
    protected $default;
40
41
    /**
42
     * @var string
43
     *
44
     * @link https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#user-content-servervariabledescription
45
     */
46
    protected $description;
47
48
    /**
49
     * @param string $name
50
     * @param string $default
51
     */
52 6
    public function __construct(string $name, string $default)
53
    {
54 6
        $this->name = $name;
55 6
        $this->default = $default;
56 6
    }
57
58
    /**
59
     * @return string
60
     */
61 2
    public function getName() : string
62
    {
63 2
        return $this->name;
64
    }
65
66
    /**
67
     * @param string ...$enum
68
     *
69
     * @return void
70
     */
71 1
    public function setEnum(string ...$enum) : void
72
    {
73 1
        $this->enum = $enum;
74 1
    }
75
76
    /**
77
     * @param string $description
78
     *
79
     * @return void
80
     */
81 1
    public function setDescription(string $description) : void
82
    {
83 1
        $this->description = $description;
84 1
    }
85
}
86