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

CampaignFactory   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 1
lcom 1
cbo 4
dl 0
loc 19
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A fields() 0 14 1
1
<?php
2
3
namespace GiveBlood\Modules\Campaign;
4
5
use GiveBlood\Modules\Users\User;
6
use GiveBlood\Support\Database\ModelFactory;
7
8
/*
9
|--------------------------------------------------------------------------
10
| User Model Factory
11
|--------------------------------------------------------------------------
12
|
13
| This directory should contain each of the model factory definitions for
14
| your application. Factories provide a convenient way to generate new
15
| model instances for testing / seeding your application's database.
16
|
17
*/
18
class CampaignFactory extends ModelFactory
19
{
20
    protected $model = Campaign::class;
21
22
    protected function fields()
23
    {
24
25
        return [
26
        'title' => $this->faker->text(60),
27
        'description' => $this->faker->text(100),
28
        'expires' => \Carbon\Carbon::now()->endOfYear(),
0 ignored issues
show
Bug introduced by
The method endOfYear 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...
29
        'image' => $this->faker->imageUrl,
30
        'user_id' =>  function () {
31
            return factory(User::class)->make()->id;
32
        },
33
        'slug' => $this->faker->slug
34
        ];
35
    }
36
}
37