Passed
Pull Request — master (#58)
by
unknown
12:21
created

Option::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 4
rs 10
1
<?php
2
/*
3
 * This file is part of the php-ansible package.
4
 *
5
 * (c) Marc Aschmann <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Asm\Ansible\Command;
12
13
/**
14
 * Class Option
15
 * @package Asm\Ansible\Command
16
 * @author  Metagûsto <[email protected]>
17
 */
18
class Option
19
{
20
    /**
21
     * @var string|null
22
     */
23
    protected $name = null;
24
    /**
25
     * @var string|null
26
     */
27
    protected $value = null;
28
29
    /**
30
     * Option constructor.
31
     * @param string|null $name
32
     * @param string|null $value
33
     */
34
    public function __construct(?string $name = null, ?string $value = null)
35
    {
36
        $this->name = $name;
37
        $this->value = $value;
38
    }
39
40
    /**
41
     * @return string|null
42
     */
43
    public function getName(): ?string
44
    {
45
        return $this->name;
46
    }
47
48
    /**
49
     * @param string|null $name
50
     */
51
    public function setName(?string $name): void
52
    {
53
        $this->name = $name;
54
    }
55
56
    /**
57
     * @return string|null
58
     */
59
    public function getValue(): ?string
60
    {
61
        return $this->value;
62
    }
63
64
    /**
65
     * @param string|null $value
66
     */
67
    public function setValue(?string $value): void
68
    {
69
        $this->value = $value;
70
    }
71
72
    /**
73
     * @return string
74
     */
75
    public function __toString()
76
    {
77
        return sprintf('%s=%s', $this->name, $this->value);
78
    }
79
80
    /**
81
     * Converts the option to string
82
     * @return string
83
     */
84
    public function toString(): string
85
    {
86
        return $this->__toString();
87
    }
88
89
    /**
90
     * @param Option|null $other
91
     * @return bool
92
     */
93
    public function equals(?Option $other)
94
    {
95
        if ($other === null)
96
            return false;
97
98
        return $this->name === $other->getName() && $this->value === $other->value;
99
    }
100
101
}