Completed
Pull Request — master (#3)
by Valentin
14:15
created

Timestamps::getTime()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
c 0
b 0
f 0
rs 9.4285
cc 2
eloc 5
nc 2
nop 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
}