Passed
Push — master ( e53bf8...383f46 )
by Brendan
03:11
created

AbstractRequestArticle::getParams()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 18
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2.351

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 18
c 0
b 0
f 0
ccs 5
cts 9
cp 0.5556
rs 9.9332
cc 2
nc 2
nop 0
crap 2.351
1
<?php
2
3
namespace Graze\WipotecCheckweigherClient\Request;
4
5
use Graze\WipotecCheckweigherClient\Parameter;
6
7
abstract class AbstractRequestArticle extends AbstractRequest
8
{
9
    /** @var string[] */
10
    private $paramIdToValue = [];
11
12
    /**
13
     * @param int $id
14
     * @param mixed $value
15
     */
16
    public function setArticleParam($id, $value)
17
    {
18
        $this->paramIdToValue[$id] = $value;
19
    }
20
21
    /**
22
     * @param int $id
23
     * @return mixed
24
     */
25
    public function getArticleParam($id)
26
    {
27
        return isset($this->paramIdToValue[$id]) ? $this->paramIdToValue[$id] : null;
28
    }
29
30
    /**
31
     * @return mixed[]
32
     */
33 1
    protected function getParams()
34
    {
35 1
        $articleParams = [];
36 1
        foreach ($this->paramIdToValue as $id => $value) {
37
            $articleParams[] = [
38
                'id' => $id,
39
                'name' => Parameter::getName($id),
40
                'value' => $value
41
            ];
42
        }
43
44
        $params = [
45
            'article_definition' => [
46 1
                'parameter' => $articleParams
47
            ]
48
        ];
49
50 1
        return $params;
51
    }
52
}
53