AsyncHttpLoggerDefault::log()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 15
ccs 10
cts 10
cp 1
rs 9.4285
cc 1
eloc 9
nc 1
nop 4
crap 1
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: Lombardo
5
 * Date: 27/12/16
6
 * Time: 15:28
7
 */
8
9
namespace AsyncHttpClient\Logger;
10
11
12
use AsyncHttpClient\Helper\Time;
13
14
class AsyncHttpLoggerDefault implements AsyncHttpLogger
15
{
16
    /**
17
     * @var array
18
     */
19
    private $logs = [];
20
21
    /**
22
     * @var Time
23
     */
24
    private $time;
25
26
    /**
27
     * AsyncHttpLoggerDefault constructor.
28
     */
29 1
    public function __construct(Time $time)
30
    {
31 1
        $this->time = $time;
32 1
    }
33
34 1
    public function log($method, $url, $data, $startTime)
35
    {
36 1
        $endTime = $this->time->now();
37
38
        // TODO: Implement log() method.
39
        $logLine = [
40 1
            'method'        => $method,
41 1
            'url'           => $url,
42 1
            'data'          => $data,
43 1
            'startTime'     => $startTime,
44 1
            'endTime'       => $endTime,
45 1
        ];
46
47 1
        $this->logs[] = $logLine;
48 1
    }
49
50 1
    public function logTotal($startTime)
51
    {
52 1
        $endTime = $this->time->now();
53 1
        $this->logs[] = ['total' => $endTime - $startTime];
54 1
    }
55
56 1
    public function getLogs()
57
    {
58 1
        return $this->logs;
59
    }
60
}