Completed
Branch master (3a127f)
by Grzegorz
21:30 queued 14:25
created

DatasetBuilder   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 44
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A build() 0 6 1
A addField() 0 6 1
A addParam() 0 6 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