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
36:02 queued 23:20
created

FieldType::getDefault()   A

Complexity

Conditions 6
Paths 5

Size

Total Lines 14
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 6
eloc 10
c 1
b 0
f 0
nc 5
nop 1
dl 0
loc 14
rs 9.2222
1
<?php
2
3
namespace Backpack\CRUD\app\Library\Components\Attributes\Fields;
4
5
use Backpack\CRUD\app\Library\Components\AttributeCollection;
6
use Backpack\CRUD\app\Library\Components\Attributes\BaseAttribute;
7
use Backpack\CRUD\app\Library\Components\Interfaces\AttributeInterface;
8
9
class FieldType extends BaseAttribute implements AttributeInterface
10
{
11
    public static function getDefault(AttributeCollection $attributes)
12
    {
13
        if (backpack_pro() && $attributes->getAttributeValue('relation_type')) {
14
            return 'relationship';
15
        }
16
17
        switch ($attributes->getAttributeValue('relation_type')) {
18
            case 'BelongsTo':
19
                return 'select';
20
            case 'BelongsToMany':
21
            case 'MorphToMany':
22
                return 'select_multiple';
23
            default:
24
                return 'text';
25
        }
26
    }
27
28
    public static function getValidationRules(): array
29
    {
30
        return ['required'];
31
    }
32
33
    public static function getAttributeName(): string
34
    {
35
        return 'type';
36
    }
37
}
38