helpers.php ➔ faveotime()   B
last analyzed

Complexity

Conditions 7
Paths 8

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 7
eloc 9
nc 8
nop 4
dl 0
loc 15
rs 8.2222
c 0
b 0
f 0
1
<?php
2
3
function loging($context, $message, $level = 'error', $array = [])
4
{
5
    \Log::$level($message.':-:-:-'.$context, $array);
6
}
7
8
function checkArray($key, $array)
9
{
10
    $value = '';
11
    if (array_key_exists($key, $array)) {
12
        $value = $array[$key];
13
    }
14
15
    return $value;
16
}
17
18
function mime($type)
19
{
20
    if ($type == 'jpg' ||
21
            $type == 'png' ||
22
            $type == 'PNG' ||
23
            $type == 'JPG' ||
24
            $type == 'jpeg' ||
25
            $type == 'JPEG' ||
26
            $type == 'gif' ||
27
            $type == 'GIF' ||
28
            $type == 'image/jpeg' ||
29
            $type == 'image/jpg' ||
30
            $type == 'image/gif' ||
31
           // $type == "application/octet-stream" ||
0 ignored issues
show
Unused Code Comprehensibility introduced by
38% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
32
            $type == 'image/png' ||
33
            starts_with($type, 'image')) {
34
        return 'image';
35
    }
36
}
37
38
function removeUnderscore($string)
39
{
40
    if (str_contains($string, '_') === true) {
41
        $string = str_replace('_', ' ', $string);
42
    }
43
44
    return ucfirst($string);
45
}
46
47
function isItil()
48
{
49
    $check = false;
50
    if (\Schema::hasTable('sd_releases') && \Schema::hasTable('sd_changes') && \Schema::hasTable('sd_problem')) {
51
        $check = true;
52
    }
53
54
    return $check;
55
}
56
57
function isAsset()
58
{
59
    $check = false;
60
    if (\Schema::hasTable('sd_assets')) {
61
        $check = true;
62
    }
63
64
    return $check;
65
}
66
67 View Code Duplication
function itilEnabled()
0 ignored issues
show
Duplication introduced by
This function seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
68
{
69
    $check = false;
70
    if (\Schema::hasTable('common_settings')) {
71
        $settings = \DB::table('common_settings')->where('option_name', 'itil')->first();
72
        if ($settings && $settings->status == 1) {
73
            $check = true;
74
        }
75
    }
76
77
    return $check;
78
}
79
80 View Code Duplication
function isBill()
0 ignored issues
show
Duplication introduced by
This function seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
81
{
82
    $check = false;
83
    if (\Schema::hasTable('common_settings')) {
84
        $settings = \DB::table('common_settings')->where('option_name', 'bill')->first();
85
        if ($settings && $settings->status == 1) {
86
            $check = true;
87
        }
88
    }
89
90
    return $check;
91
}
92
93 View Code Duplication
function deletePopUp($id, $url, $title = 'Delete', $class = 'btn btn-sm btn-danger', $btn_name = 'Delete', $button_check = true)
0 ignored issues
show
Duplication introduced by
This function seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
94
{
95
    $button = '';
96
    if ($button_check == true) {
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like you are loosely comparing two booleans. Considering using the strict comparison === instead.

When comparing two booleans, it is generally considered safer to use the strict comparison operator.

Loading history...
97
        $button = '<a href="#delete" class="'.$class.'" data-toggle="modal" data-target="#delete'.$id.'">'.$btn_name.'</a>';
98
    }
99
100
    return $button.'<div class="modal fade" id="delete'.$id.'">
101
                    <div class="modal-dialog">
102
                        <div class="modal-content">
103
                            <div class="modal-header">
104
                                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
105
                                <h4 class="modal-title">'.$title.'</h4>
106
                            </div>
107
                            <div class="modal-body">
108
                                <div class="row">
109
                                <div class="col-md-12">
110
                                <p>Are you sure ?</p>
111
                                </div>
112
                                </div>
113
                            </div>
114
                            <div class="modal-footer">
115
                                <button type="button" id="close" class="btn btn-default pull-left" data-dismiss="modal">Close</button>
116
                                <a href="'.$url.'" class="btn btn-danger">Delete</a>
117
                            </div>
118
                        </div>
119
                    </div>
120
                </div>';
121
}
122
123
function isInstall()
124
{
125
    $check = false;
126
    $env = base_path('.env');
127
    if (\File::exists($env) && env('DB_INSTALL') == 1) {
128
        $check = true;
129
    }
130
131
    return $check;
132
}
133
134
function faveotime($date, $hour = 0, $min = 0, $sec = 0)
135
{
136
    if (is_bool($hour) && $hour == true) {
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like you are loosely comparing two booleans. Considering using the strict comparison === instead.

When comparing two booleans, it is generally considered safer to use the strict comparison operator.

Loading history...
137
        $hour = $date->hour;
138
    }
139
    if (is_bool($min) && $min == true) {
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like you are loosely comparing two booleans. Considering using the strict comparison === instead.

When comparing two booleans, it is generally considered safer to use the strict comparison operator.

Loading history...
140
        $min = $date->minute;
141
    }
142
    if (is_bool($sec) && $sec == true) {
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like you are loosely comparing two booleans. Considering using the strict comparison === instead.

When comparing two booleans, it is generally considered safer to use the strict comparison operator.

Loading history...
143
        $sec = $date->second;
144
    }
145
    $date1 = \Carbon\Carbon::create($date->year, $date->month, $date->day, $hour, $min, $sec);
146
147
    return $date1->hour($hour)->minute($min)->second($sec);
148
}
149