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

Passed
Pull Request — main (#4854)
by Pedro
40:26 queued 25:42
created

MultipleAttribute::getDefault()   B

Complexity

Conditions 8
Paths 8

Size

Total Lines 16
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 8
eloc 12
c 1
b 0
f 0
nc 8
nop 1
dl 0
loc 16
rs 8.4444
1
<?php
2
3
namespace Backpack\CRUD\app\Library\Components\Attributes;
4
5
use Backpack\CRUD\app\Library\Components\AttributeCollection;
6
use Backpack\CRUD\app\Library\Components\Interfaces\AttributeInterface;
7
8
class MultipleAttribute extends BackpackAttribute implements AttributeInterface
9
{
10
    public static function getDefault(AttributeCollection $attributes)
11
    {
12
        switch ($attributes->getAttributeValue('relation_type')) {
13
            case 'BelongsToMany':
14
            case 'HasMany':
15
            case 'HasManyThrough':
16
            case 'HasOneOrMany':
17
            case 'MorphMany':
18
            case 'MorphOneOrMany':
19
            case 'MorphToMany':
20
                return true;
21
            default:
22
                return false;
23
        }
24
25
        return false;
0 ignored issues
show
Unused Code introduced by
return false is not reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
26
    }
27
28
    public static function getValidationRules(): array
29
    {
30
        return ['nullable|string'];
31
    }
32
33
    public static function getAttributeName(): string
34
    {
35
        return 'relation_type';
36
    }
37
}
38