AbstractRequestArticle   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Test Coverage

Coverage 43.75%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
eloc 14
c 1
b 0
f 0
dl 0
loc 44
ccs 7
cts 16
cp 0.4375
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 1
        }
43
44
        $params = [
45
            'article_definition' => [
46
                'parameter' => $articleParams
47 1
            ]
48 1
        ];
49
50 1
        return $params;
51
    }
52
}
53