Passed
Branch master (d0211e)
by Willy
02:44
created

CriteriaService   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 38
ccs 0
cts 22
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A prepareCriteriaValueObject() 0 9 1
A prepareMultipleCriteriaValueObject() 0 15 2
1
<?php
2
3
namespace Kubinashi\BattlenetApi\WorldOfWarcraft\Shared\Criteria\Service;
4
5
use Kubinashi\BattlenetApi\WorldOfWarcraft\Shared\Criteria\Model\CriteriaValueObject;
6
7
/**
8
 * @author  Willy Reiche
9
 * @since   2017-08-22
10
 * @version 1.0
11
 */
12
class CriteriaService
13
{
14
    /**
15
     * @param \StdClass $criteria
16
     *
17
     * @return CriteriaValueObject
18
     */
19
    public function prepareCriteriaValueObject($criteria)
20
    {
21
        return new CriteriaValueObject(
22
            $criteria->id,
23
            $criteria->description,
24
            $criteria->orderIndex,
25
            $criteria->max
26
        );
27
    }
28
29
    /**
30
     * @param \StdClass[] $criteria
31
     *
32
     * @return CriteriaValueObject[]
33
     */
34
    public function prepareMultipleCriteriaValueObject($criteria)
35
    {
36
        $criteriaValueObjects = [];
37
38
        foreach ($criteria as $criterion) {
39
            $criteriaValueObjects[] = new CriteriaValueObject(
40
                $criterion->id,
41
                $criterion->description,
42
                $criterion->orderIndex,
43
                $criterion->max
44
            );
45
        }
46
47
        return $criteriaValueObjects;
48
    }
49
}
50