MoneyType   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 0
dl 0
loc 42
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A toArray() 0 9 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