Timestamps   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A getTime() 0 10 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
}