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
30:01 queued 14:59
created

FieldType   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
c 1
b 0
f 0
dl 0
loc 27
rs 10
wmc 8

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getAttributeName() 0 3 1
A getDefault() 0 14 6
A getValidationRules() 0 3 1
1
<?php
2
3
namespace Backpack\CRUD\app\Library\Components\Attributes\Fields;
4
5
use Backpack\CRUD\app\Library\Components\Attributes\BaseAttribute;
6
use Backpack\CRUD\app\Library\Components\Interfaces\SmartAttributeInterface;
7
use Backpack\CRUD\app\Library\Components\Interfaces\SmartCollectionInterface;
8
9
class FieldType extends BaseAttribute implements SmartAttributeInterface
10
{
11
    public static function getDefault(SmartCollectionInterface $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(SmartCollectionInterface $attributes): array
29
    {
30
        return ['required'];
31
    }
32
33
    public static function getAttributeName(): string
34
    {
35
        return 'type';
36
    }
37
}
38