Interpreter::transformLines()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
namespace DeGraciaMathieu\Clike;
4
5
use DateTime;
6
7
class Interpreter {
8
9
    /**
10
     * Get command response
11
     * @param  \DeGraciaMathieu\Clike\Contracts\Output $output
12
     * @return array
13
     */
14 3
    public static function read(Contracts\Output $output) :array
15
    {
16 3
        $datetime = new DateTime();
17
18
        return [
19 3
            'timestamp' => $datetime->getTimestamp(),
20 3
            'lines' => self::transformLines($output),
21
        ];	
22
    }
23
24
    /**
25
     * Retrieve command lines
26
     * @param  \DeGraciaMathieu\Clike\Contracts\Output $output
27
     * @return array
28
     */
29 3
    protected static function transformLines(Contracts\Output $output) :array
30
    {
31
        return array_map(function($line) {
32 3
            return $line->read();
33 3
        }, $output->get());
34
    }
35
}
36