Completed
Push — master ( 1cd2c7...bcc930 )
by Guillermo
10s
created

Method::setReturn()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 9.4285
c 0
b 0
f 0
nc 1
cc 1
eloc 3
nop 1
crap 1
1
<?php
2
3
namespace Atrapalo\PHPTools\Parser\Values;
4
5
/**
6
 * Class Method
7
 * @package Atrapalo\PHPTools\Parser\Values
8
 *
9
 * @author Guillermo González <[email protected]>
10
 */
11
class Method
12
{
13
    /** @var bool */
14
    private $isStatic;
15
    /** @var string */
16
    private $name;
17
    /** @var string */
18
    private $return;
19
    /** @var Param[] */
20
    private $params;
21
    /** @var string */
22
    private $description;
23
24
    /**
25
     * Method constructor.
26
     * @param bool   $isStatic
27
     * @param string $name
28
     */
29 4
    public function __construct(bool $isStatic, string $name)
30
    {
31 4
        $this->isStatic = $isStatic;
32 4
        $this->setName($name);
33 4
    }
34
35
    /**
36
     * @return bool
37
     */
38
    public function isStatic(): bool
39
    {
40
        return $this->isStatic;
41
    }
42
43
    /**
44
     * @return string
45
     */
46 4
    public function name(): string
47
    {
48 4
        return $this->name;
49
    }
50
51
    /**
52
     * @param string $name
53
     * @return Method
54
     */
55 4
    private function setName(string $name)
56
    {
57 4
        if (empty($name)) {
58
            throw new \InvalidArgumentException('Name is mandatory and can not be empty');
59
        }
60
61 4
        $this->name = $name;
62
63 4
        return $this;
64
    }
65
66
    /**
67
     * @return string
68
     */
69 2
    public function return ()
70
    {
71 2
        return $this->return;
72
    }
73
74
    /**
75
     * @param string $return
76
     * @return Method
77
     */
78 4
    public function setReturn(string $return)
79
    {
80 4
        $this->return = $return;
81
82 4
        return $this;
83
    }
84
85
    /**
86
     * @return Param[]
87
     */
88 2
    public function params()
89
    {
90 2
        return $this->params;
91
    }
92
93
    /**
94
     * @param Param[] $params
95
     * @return Method
96
     */
97 4
    public function setParams(array $params)
98
    {
99 4
        $this->params = $params;
100
101 4
        return $this;
102
    }
103
104
    /**
105
     * @return string
106
     */
107
    public function description()
108
    {
109
        return $this->description;
110
    }
111
112
    /**
113
     * @param string $description
114
     * @return Method
115
     */
116 4
    public function setDescription(string $description)
117
    {
118 4
        $this->description = $description;
119
120 4
        return $this;
121
    }
122
}
123