ResponseReadActiveArticle   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
eloc 9
c 1
b 0
f 0
dl 0
loc 28
ccs 0
cts 14
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getArticleParam() 0 3 2
A parseContents() 0 10 3
1
<?php
2
3
namespace Graze\WipotecCheckweigherClient\Response;
4
5
class ResponseReadActiveArticle extends AbstractResponse
6
{
7
    /** @var string[] */
8
    private $paramIdToValue;
9
10
    /**
11
     * @param mixed[] $contents
12
     */
13
    protected function parseContents(array $contents)
14
    {
15
        if (!isset($contents['article_definition']['parameter'])) {
16
            return;
17
        }
18
19
        foreach ($contents['article_definition']['parameter'] as $param) {
20
            $id = $param['id'];
21
            $value = $param['value'];
22
            $this->paramIdToValue[$id] = $value;
23
        }
24
    }
25
26
    /**
27
     * @param int $id
28
     * @return string
29
     */
30
    public function getArticleParam($id)
31
    {
32
        return isset($this->paramIdToValue[$id]) ? $this->paramIdToValue[$id] : null;
33
    }
34
}
35