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

CriteriaService::prepareCriteriaValueObject()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 0
cts 9
cp 0
rs 9.6666
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 1
crap 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