Field   A
last analyzed

Complexity

Total Complexity 11

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 11
eloc 14
c 2
b 0
f 0
dl 0
loc 60
rs 10

11 Methods

Rating   Name   Duplication   Size   Complexity  
A ID() 0 3 1
A string() 0 3 1
A list() 0 3 1
A model() 0 3 1
A int() 0 3 1
A getRegistry() 0 3 1
A float() 0 3 1
A boolean() 0 3 1
A type() 0 3 1
A collection() 0 3 1
A polymorphic() 0 3 1
1
<?php
2
3
namespace Bakery;
4
5
use Bakery\Support\TypeRegistry;
6
use Bakery\Fields\PolymorphicField;
7
use Illuminate\Support\Traits\Macroable;
8
9
class Field
10
{
11
    use Macroable;
0 ignored issues
show
Bug introduced by
The trait Illuminate\Support\Traits\Macroable requires the property $name which is not provided by Bakery\Field.
Loading history...
12
13
    /**
14
     * Get the current bound registry.
15
     */
16
    public static function getRegistry(): TypeRegistry
17
    {
18
        return resolve(TypeRegistry::class);
19
    }
20
21
    public static function string(): Fields\Field
22
    {
23
        return self::getRegistry()->field(self::getRegistry()->string());
24
    }
25
26
    public static function int(): Fields\Field
27
    {
28
        return self::getRegistry()->field(self::getRegistry()->int());
29
    }
30
31
    public static function ID(): Fields\Field
32
    {
33
        return self::getRegistry()->field(self::getRegistry()->ID());
34
    }
35
36
    public static function boolean(): Fields\Field
37
    {
38
        return self::getRegistry()->field(self::getRegistry()->boolean());
39
    }
40
41
    public static function float(): Fields\Field
42
    {
43
        return self::getRegistry()->field(self::getRegistry()->float());
44
    }
45
46
    public static function model(string $class): Fields\EloquentField
47
    {
48
        return self::getRegistry()->eloquent($class);
49
    }
50
51
    public static function collection(string $class): Fields\EloquentField
52
    {
53
        return self::model($class)->list();
54
    }
55
56
    public static function type(string $type): Fields\Field
57
    {
58
        return self::getRegistry()->field($type);
59
    }
60
61
    public static function list(string $type): Fields\Field
62
    {
63
        return self::type($type)->list();
64
    }
65
66
    public static function polymorphic(array $modelSchemas): PolymorphicField
67
    {
68
        return self::getRegistry()->polymorphic($modelSchemas);
69
    }
70
}
71