Timestamps::getTime()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
cc 2
nc 2
nop 2
1
<?php
2
3
namespace Spiral\LogViewer\Helpers;
4
5
use Carbon\Carbon;
6
7
class Timestamps
8
{
9
    /**
10
     * @param mixed $timestamp
11
     * @param bool  $relative
12
     * @return string
13
     */
14
    public function getTime($timestamp, bool $relative = false): string
15
    {
16
        if (empty($relative)) {
17
            return $timestamp;
18
        }
19
20
        $carbon = new Carbon($timestamp);
21
22
        return $carbon->diffForHumans($carbon->now());
23
    }
24
}