MoneyType::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 3
crap 1
1
<?php
2
3
namespace Kwk\Geckoboard\Dataset\Type;
4
5
use Kwk\Geckoboard\Dataset\TypeInterface;
6
7
class MoneyType implements TypeInterface
8
{
9
    /**
10
     * @var string
11
     */
12
    private $name;
13
14
    /**
15
     * @var bool
16
     */
17
    private $isOptional;
18
19
    /**
20
     * @var string
21
     */
22
    private $currency;
23
24
    /**
25
     * @param string $name
26
     * @param string $currency
27
     * @param bool   $isOptional
28
     */
29 3
    public function __construct($name, $currency, $isOptional = false)
30
    {
31 3
        $this->name       = $name;
32 3
        $this->currency   = $currency;
33 3
        $this->isOptional = $isOptional;
34 3
    }
35
36
    /**
37
     * {@inheritDoc}
38
     */
39 2
    public function toArray()
40
    {
41
        return [
42 2
            'type'          => 'money',
43 2
            'name'          => $this->name,
44 2
            'currency_code' => $this->currency,
45 2
            'optional'      => $this->isOptional,
46
        ];
47
    }
48
}
49