Passed
Pull Request — development (#682)
by Nick
07:09
created

StructMapper::map()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 16
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 10
nc 2
nop 1
dl 0
loc 16
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Oc\FieldNotes\Import;
4
5
use Oc\FieldNotes\Struct\FieldNote;
6
7
/**
8
 * Class StructMapper
9
 *
10
 * @package Oc\FieldNotes\Import
0 ignored issues
show
introduced by
Unexpected tag type @package in doc block
Loading history...
11
 */
12
class StructMapper
13
{
14
    /**
15
     * Maps given array to field note struct.
16
     *
17
     * @param array $rows
18
     *
19
     * @return FieldNote[]
0 ignored issues
show
introduced by
FieldNote[] => \Oc\FieldNotes\Struct\FieldNote[]
Loading history...
20
     */
21
    public function map(array $rows)
22
    {
23
        $fieldNotes = [];
24
25
        foreach ($rows as $row) {
26
            $fieldNote = new FieldNote();
27
            $fieldNote->waypoint = $row[0];
28
            $fieldNote->noticedAt = $row[1];
29
            $fieldNote->logType = $row[2];
30
            $fieldNote->notice = $row[3];
31
32
            $fieldNotes[] = $fieldNote;
33
        }
34
35
        return $fieldNotes;
36
    }
37
}
38