AbstractRequestArticle::getParams()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 18
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 2.1922

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 18
ccs 7
cts 11
cp 0.6364
rs 9.9332
cc 2
nc 2
nop 0
crap 2.1922
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 1
        }
43
44
        $params = [
45
            'article_definition' => [
46
                'parameter' => $articleParams
47 1
            ]
48 1
        ];
49
50 1
        return $params;
51
    }
52
}
53