Completed
Push — 0.2.x-dev ( a47afe...3a127f )
by Grzegorz
11:54
created

DatasetBuilder::addParam()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 1
1
<?php
2
3
namespace Kwk\Geckoboard\Dataset;
4
5
class DatasetBuilder
6
{
7
    private $fields     = [];
8
    private $parameters = [];
9
10
    /**
11
     * @return array
12
     */
13 6
    public function build()
14
    {
15
        return [
16 6
            'fields' => $this->fields,
17 6
        ] + $this->parameters;
18
    }
19
20
    /**
21
     * @param string        $id
22
     * @param TypeInterface $fieldDefinition
23
     *
24
     * @return $this
25
     *
26
     */
27 5
    public function addField($id, TypeInterface $fieldDefinition)
28
    {
29 5
        $this->fields[$id] = $fieldDefinition->toArray();
30
31 5
        return $this;
32
    }
33
34
    /**
35
     * Adding custom parameter to dataset
36
     *
37
     * @param string $paramName
38
     * @param string $value
39
     *
40
     * @return $this
41
     */
42 2
    public function addParam($paramName, $value)
43
    {
44 2
        $this->parameters[$paramName] = $value;
45
46 2
        return $this;
47
    }
48
}
49