AppServiceProvider::boot()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 3
eloc 6
c 2
b 0
f 0
nc 2
nop 0
dl 0
loc 12
rs 10
1
<?php
2
3
namespace App\Providers;
4
5
use App\Judite\Models\Settings;
6
use Illuminate\Support\Facades\App;
7
use Illuminate\Support\Facades\URL;
8
use Illuminate\Support\Facades\Auth;
9
use Illuminate\Support\ServiceProvider;
10
use Illuminate\Support\Facades\Validator;
11
use App\Judite\Registry\EloquentExchangeRegistry;
12
use App\Judite\Contracts\Registry\ExchangeRegistry;
13
14
class AppServiceProvider extends ServiceProvider
15
{
16
    /**
17
     * Bootstrap any application services.
18
     */
19
    public function boot()
20
    {
21
        if (App::environment('production')) {
0 ignored issues
show
Unused Code introduced by
The call to Illuminate\Support\Facades\App::environment() has too many arguments starting with 'production'. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

21
        if (App::/** @scrutinizer ignore-call */ environment('production')) {

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
22
            URL::forceScheme('https');
23
        }
24
25
        Auth::macro('student', function () {
26
            return Auth::check() ? Auth::user()->student : null;
0 ignored issues
show
Bug introduced by
Accessing student on the interface Illuminate\Contracts\Auth\Authenticatable suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
27
        });
28
29
        Validator::extend('student_number', function ($attribute, $value, $parameters, $validator) {
0 ignored issues
show
Unused Code introduced by
The parameter $validator is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

29
        Validator::extend('student_number', function ($attribute, $value, $parameters, /** @scrutinizer ignore-unused */ $validator) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $parameters is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

29
        Validator::extend('student_number', function ($attribute, $value, /** @scrutinizer ignore-unused */ $parameters, $validator) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
30
            return preg_match('/^(a|pg)[0-9]+$/i', $value) === 1;
31
        });
32
    }
33
34
    /**
35
     * Register any application services.
36
     */
37
    public function register()
38
    {
39
        $this->app->singleton(ExchangeRegistry::class, function ($app) {
0 ignored issues
show
Unused Code introduced by
The parameter $app is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

39
        $this->app->singleton(ExchangeRegistry::class, function (/** @scrutinizer ignore-unused */ $app) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
40
            return new EloquentExchangeRegistry();
41
        });
42
43
        $this->app->singleton('settings', function ($app) {
0 ignored issues
show
Unused Code introduced by
The parameter $app is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

43
        $this->app->singleton('settings', function (/** @scrutinizer ignore-unused */ $app) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
44
            return Settings::firstOrNew([]);
45
        });
46
    }
47
}
48