StationMapper::map()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 3

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 13
ccs 9
cts 9
cp 1
rs 9.4285
cc 3
eloc 7
nc 3
nop 1
crap 3
1
<?php
2
3
namespace Sl\Mappers;
4
5
use Sl\Station;
6
use Sl\Contracts\MapperInterface;
7
8
class StationMapper implements MapperInterface
9
{
10
    /**
11
     * Map data to array of object instance.
12
     *
13
     * @param array $data
14
     *
15
     * @return array
16
     */
17 2
    public function map(array $data)
18
    {
19 2
        $data = $data['data'];
20 2
        $stations = [];
21
22 2
        foreach ($data as $place) {
23 2
            if ($place['Type'] === 'station') {
24 2
                $stations[] = new Station($place['SiteId'], $place['Name']);
25 2
            }
26 2
        }
27
28 2
        return $stations;
29
    }
30
}
31