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

Param::setName()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2.032

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 4
cts 5
cp 0.8
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 5
nc 2
nop 1
crap 2.032
1
<?php
2
3
namespace Atrapalo\PHPTools\Parser\Values;
4
5
/**
6
 * Class Param
7
 * @package Atrapalo\PHPTools\Parser\Values
8
 *
9
 * @author Guillermo González <[email protected]>
10
 */
11
class Param
12
{
13
    /** @var string */
14
    private $name;
15
    /** @var string */
16
    private $type;
17
18
    /**
19
     * Param constructor.
20
     * @param string $name
21
     * @param string $type
22
     */
23 2
    public function __construct($name, $type = '')
24
    {
25 2
        $this->setName($name);
26 2
        $this->type = $type;
27 2
    }
28
29
    /**
30
     * @return string
31
     */
32
    public function name(): string
33
    {
34
        return $this->name;
35
    }
36
37
    /**
38
     * @param string $name
39
     * @return Param
40
     */
41 2
    private function setName(string $name)
42
    {
43 2
        if (empty($name)) {
44
            throw new \InvalidArgumentException('Name is mandatory and can not be empty');
45
        }
46
47 2
        $this->name = $name;
48
49 2
        return $this;
50
    }
51
52
    /**
53
     * @return string
54
     */
55
    public function type(): string
56
    {
57
        return $this->type;
58
    }
59
}
60