Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Test Setup Failed
Pull Request — master (#3127)
by
unknown
28:44 queued 16:13
created

is_countable()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 1
nc 2
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
if (! function_exists('backpack_url')) {
4
    /**
5
     * Appends the configured backpack prefix and returns
6
     * the URL using the standard Laravel helpers.
7
     *
8
     * @param $path
9
     *
10
     * @return string
11
     */
12
    function backpack_url($path = null, $parameters = [], $secure = null)
13
    {
14
        $path = ! $path || (substr($path, 0, 1) == '/') ? $path : '/'.$path;
15
16
        return url(config('backpack.base.route_prefix', 'admin').$path, $parameters, $secure);
17
    }
18
}
19
20
if (! function_exists('backpack_authentication_column')) {
21
    /**
22
     * Return the username column name.
23
     * The Laravel default (and Backpack default) is 'email'.
24
     *
25
     * @return string
26
     */
27
    function backpack_authentication_column()
28
    {
29
        return config('backpack.base.authentication_column', 'email');
30
    }
31
}
32
33
if (! function_exists('backpack_users_have_email')) {
34
    /**
35
     * Check if the email column is present on the user table.
36
     *
37
     * @return string
38
     */
39
    function backpack_users_have_email()
40
    {
41
        $user_model_fqn = config('backpack.base.user_model_fqn');
42
        $user = new $user_model_fqn();
43
44
        return \Schema::hasColumn($user->getTable(), 'email');
0 ignored issues
show
Bug Best Practice introduced by
The expression return Schema::hasColumn...r->getTable(), 'email') returns the type boolean which is incompatible with the documented return type string.
Loading history...
45
    }
46
}
47
48
if (! function_exists('backpack_avatar_url')) {
49
    /**
50
     * Returns the avatar URL of a user.
51
     *
52
     * @param $user
53
     *
54
     * @return string
55
     */
56
    function backpack_avatar_url($user)
57
    {
58
        $firstLetter = $user->getAttribute('name') ? mb_substr($user->name, 0, 1, 'UTF-8') : 'A';
59
        $placeholder = 'https://placehold.it/160x160/00a65a/ffffff/&text='.$firstLetter;
60
61
        switch (config('backpack.base.avatar_type')) {
62
            case 'gravatar':
63
                if (backpack_users_have_email()) {
64
                    return Gravatar::fallback('https://placehold.it/160x160/00a65a/ffffff/&text='.$firstLetter)->get($user->email);
0 ignored issues
show
Bug introduced by
The type Gravatar was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
65
                } else {
66
                    return $placeholder;
67
                }
68
                break;
69
70
            case 'placehold':
71
                return $placeholder;
72
                break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
73
74
            default:
75
                return method_exists($user, config('backpack.base.avatar_type')) ? $user->{config('backpack.base.avatar_type')}() : $user->{config('backpack.base.avatar_type')};
76
                break;
77
        }
78
    }
79
}
80
81
if (! function_exists('backpack_middleware')) {
82
    /**
83
     * Return the key of the middleware used across Backpack.
84
     * That middleware checks if the visitor is an admin.
85
     *
86
     * @param $path
87
     *
88
     * @return string
89
     */
90
    function backpack_middleware()
91
    {
92
        return config('backpack.base.middleware_key', 'admin');
93
    }
94
}
95
96
if (! function_exists('backpack_guard_name')) {
97
    /*
98
     * Returns the name of the guard defined
99
     * by the application config
100
     */
101
    function backpack_guard_name()
102
    {
103
        return config('backpack.base.guard', config('auth.defaults.guard'));
104
    }
105
}
106
107
if (! function_exists('backpack_auth')) {
108
    /*
109
     * Returns the user instance if it exists
110
     * of the currently authenticated admin
111
     * based off the defined guard.
112
     */
113
    function backpack_auth()
114
    {
115
        return \Auth::guard(backpack_guard_name());
116
    }
117
}
118
119
if (! function_exists('backpack_user')) {
120
    /*
121
     * Returns back a user instance without
122
     * the admin guard, however allows you
123
     * to pass in a custom guard if you like.
124
     */
125
    function backpack_user()
126
    {
127
        return backpack_auth()->user();
128
    }
129
}
130
131
if (! function_exists('mb_ucfirst')) {
132
    /**
133
     * Capitalize the first letter of a string,
134
     * even if that string is multi-byte (non-latin alphabet).
135
     *
136
     * @param string   $string   String to have its first letter capitalized.
137
     * @param encoding $encoding Character encoding
0 ignored issues
show
Bug introduced by
The type encoding was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
138
     *
139
     * @return string String with first letter capitalized.
140
     */
141
    function mb_ucfirst($string, $encoding = false)
142
    {
143
        $encoding = $encoding ? $encoding : mb_internal_encoding();
144
145
        $strlen = mb_strlen($string, $encoding);
146
        $firstChar = mb_substr($string, 0, 1, $encoding);
147
        $then = mb_substr($string, 1, $strlen - 1, $encoding);
148
149
        return mb_strtoupper($firstChar, $encoding).$then;
150
    }
151
}
152
153
if (! function_exists('backpack_view')) {
154
    /**
155
     * Returns a new displayable view based on the configured backpack view namespace.
156
     * If that view doesn't exist, it will load the one from the original theme.
157
     *
158
     * @param string (see config/backpack/base.php)
0 ignored issues
show
Documentation Bug introduced by
The doc comment (see at position 1 could not be parsed: Expected ')' at position 1, but found 'see'.
Loading history...
159
     *
160
     * @return string
161
     */
162
    function backpack_view($view)
163
    {
164
        $originalTheme = 'backpack::';
165
        $theme = config('backpack.base.view_namespace');
166
167
        if (is_null($theme)) {
168
            $theme = $originalTheme;
169
        }
170
171
        $returnView = $theme.$view;
172
173
        if (! view()->exists($returnView)) {
174
            $returnView = $originalTheme.$view;
175
        }
176
177
        return $returnView;
178
    }
179
}
180
181
if (! function_exists('square_brackets_to_dots')) {
182
    /**
183
     * Turns a string from bracket-type array to dot-notation array.
184
     * Ex: array[0][property] turns into array.0.property.
185
     *
186
     * @param $path
187
     *
188
     * @return string
189
     */
190
    function square_brackets_to_dots($string)
191
    {
192
        $string = str_replace(['[', ']'], ['.', ''], $string);
193
194
        return $string;
195
    }
196
}
197
198
if (! function_exists('is_countable')) {
199
    /**
200
     * We need this because is_countable was only introduced in PHP 7.3,
201
     * and in PHP 7.2 you should check if count() argument is really countable.
202
     * This function may be removed in future if PHP >= 7.3 becomes a requirement.
203
     *
204
     * @param $obj
205
     *
206
     * @return bool
207
     */
208
    function is_countable($obj)
209
    {
210
        return is_array($obj) || $obj instanceof Countable;
211
    }
212
}
213