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

AbstractRequestArticle   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Test Coverage

Coverage 35.7%

Importance

Changes 0
Metric Value
wmc 5
eloc 14
dl 0
loc 44
c 0
b 0
f 0
ccs 5
cts 14
cp 0.357
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setArticleParam() 0 3 1
A getArticleParam() 0 3 2
A getParams() 0 18 2
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