Test Setup Failed
Push — development ( 057645...ac5058 )
by Ashutosh
15:58
created

helpers.php ➔ agoratime()   B

Complexity

Conditions 8
Paths 16

Size

Total Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 8
nc 16
nop 5
dl 0
loc 18
rs 8.4444
c 0
b 0
f 0
1
<?php
2
3
function checkArray($key, $array)
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
4
{
5
    $value = '';
6
    if (is_array($array) && array_key_exists($key, $array)) {
7
        $value = $array[$key];
8
    }
9
10
    return $value;
11
}
12
13
function mime($type)
14
{
15
    if ($type == 'jpg' ||
16
            $type == 'png' ||
17
            $type == 'jpeg' ||
18
            $type == 'gif' ||
19
            $type == 'image/jpeg' ||
20
            $type == 'image/jpg' ||
21
            $type == 'image/gif' ||
22
            $type == 'image/png' ||
23
            starts_with($type, 'image')) {
24
        return 'image';
25
    }
26
}
27
28
function isInstall()
29
{
30
    $check = false;
31
    $env = base_path('.env');
32
    if (\File::exists($env) && env('DB_INSTALL') == 1) {
33
        $check = true;
34
    }
35
36
    return $check;
37
}
38
39
function agoratime($date, $hour = 0, $min = 0, $sec = 0, $tz = '')
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $tz. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
40
{
41
    if (is_bool($hour) && $hour === true) {
42
        $hour = $date->hour;
43
    }
44
    if (is_bool($min) && $min === true) {
45
        $min = $date->minute;
46
    }
47
    if (is_bool($sec) && $sec === true) {
48
        $sec = $date->second;
49
    }
50
    if (!$tz) {
51
        $tz = /* @scrutinizer ignore-call */ timezone();
52
    }
53
    $date1 = \Carbon\Carbon::create($date->year, $date->month, $date->day, $hour, $min, $sec, $tz);
54
55
    return $date1->hour($hour)->minute($min)->second($sec);
56
}
57