GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

GeniusHelper::hourToEpoch()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 10
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: htinlynn
5
 * Date: 11/26/18
6
 * Time: 4:11 PM
7
 */
8
9
namespace Genius\Traits;
10
11
12
use Carbon\Carbon;
13
14
trait GeniusHelper
15
{
16
    /**
17
     * @param $value
18
     * @return float|int|null
19
     */
20
    public function dateToEpoch($value)
21
    {
22
        if ($value === null) {
23
            return null;
24
        }
25
        return Carbon::parse($value)->timestamp * 1000;
26
    }
27
28
    /**
29
     * @param $value
30
     * @return float|int|null
31
     */
32
    public function hourToEpoch($value)
33
    {
34
        if ($value === null) {
35
            return null;
36
        }
37
        $time = Carbon::parse($value);
38
        $hour = $time->format('H');
39
        $minutes = $time->format('i');
40
        $seconds = $time->format('s');
41
        return ($hour * 3600 + $minutes * 60 * $seconds) * 1000;
42
    }
43
44
    /**
45
     * @param $value
46
     * @return null|string
47
     */
48
    public function epochToHour($value)
49
    {
50
        if ($value === null) {
51
            return null;
52
        }
53
        return Carbon::createFromTimeStampUTC($value / 1000)->toTimeString();
54
    }
55
56
    /**
57
     * @param $value
58
     * @return null|string
59
     */
60
    public function epochToDate($value)
61
    {
62
        if ($value === null) {
63
            return null;
64
        }
65
        return Carbon::createFromTimeStampUTC($value / 1000)->toDateString();
66
    }
67
68
    /**
69
     * @param $value
70
     * @return null|string
71
     */
72
    public function toDateFormat($value)
73
    {
74
        return Carbon::parse($value)->format('d/m/y');
75
    }
76
77
    /**
78
     * @param $value
79
     * @param $format
80
     * @return null|string
81
     */
82
    public function epochToDateByDateFormat($value, $format)
83
    {
84
        if ($value == null) {
85
            return null;
86
        }
87
        return Carbon::createFromTimeStampUTC($value / 1000)->format($format);
88
    }
89
}
90