Passed
Push — master ( 2fd9d4...f7bb52 )
by Valentin
01:08
created

Timestamps   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 18
c 0
b 0
f 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A getTime() 0 10 2
1
<?php
2
3
namespace Spiral\Snapshotter\Helpers;
4
5
use Carbon\Carbon;
6
use Spiral\Snapshotter\AggregationHandler\Database\IncidentRecord;
7
use Spiral\Snapshotter\AggregationHandler\Database\SnapshotRecord;
8
9
class Timestamps
10
{
11
    /**
12
     * @param mixed $timestamp
13
     * @param bool  $relative
14
     * @return string
15
     */
16
    public function getTime($timestamp, bool $relative = false): string
17
    {
18
        if (empty($relative)) {
19
            return $timestamp;
20
        }
21
22
        $carbon = new Carbon($timestamp);
23
24
        return $carbon->diffForHumans($carbon->now());
25
    }
26
}