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

Param   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 61.53%

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 0
dl 0
loc 49
ccs 8
cts 13
cp 0.6153
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A name() 0 4 1
A setName() 0 10 2
A type() 0 4 1
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