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 — development (#68)
by José
06:06
created

AppServiceProvider::boot()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 13
rs 9.8333
c 0
b 0
f 0
cc 2
nc 1
nop 0
1
<?php
2
3
namespace GiveBlood\Units\Core\Providers;
4
5
use Illuminate\Support\ServiceProvider;
6
7
class AppServiceProvider extends ServiceProvider
8
{
9
    /**
10
     * Register any application services.
11
     *
12
     * @return void
13
     */
14
    public function register()
15
    {
16
        //
17
    }
18
19
    /**
20
     * Bootstrap any application services.
21
     *
22
     * @return void
23
     */
24
    public function boot()
25
    {
26
        //  User::observe(UserObserver::class);
27
28
        // Extend the Validator class.
29
        // To check the user age (minimum: 16)
30
        \Validator::extend(
31
            'olderThan', function ($attributes, $value, $parameters) {
32
                $minAge = (!empty($parameters)) ? (int) $parameters[ 0 ] : 16;
33
                return \Carbon\Carbon::now()->diff(new \Carbon\Carbon($value))->y >= $minAge;
0 ignored issues
show
Bug introduced by
The method diff does only exist in Carbon\CarbonInterface, but not in Carbon\Traits\Creator.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
34
            }
35
        );
36
    }
37
}
38