NumberType::toArray()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 8
Ratio 100 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 8
loc 8
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Kwk\Geckoboard\Dataset\Type;
4
5
use Kwk\Geckoboard\Dataset\TypeInterface;
6
7 View Code Duplication
class NumberType implements TypeInterface
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
8
{
9
    /**
10
     * @var string
11
     */
12
    private $name;
13
14
    /**
15
     * @var bool
16
     */
17
    private $isOptional;
18
19
    /**
20
     * @param string $name
21
     * @param bool   $isOptional
22
     */
23 4
    public function __construct($name, $isOptional = false)
24
    {
25 4
        $this->name       = $name;
26 4
        $this->isOptional = $isOptional;
27 4
    }
28
29
    /**
30
     * {@inheritDoc}
31
     */
32 3
    public function toArray()
33
    {
34
        return [
35 3
            'type'     => 'number',
36 3
            'name'     => $this->name,
37 3
            'optional' => $this->isOptional,
38
        ];
39
    }
40
}
41