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::getValidationRules()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
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