Passed
Push — master ( 4a3edd...e1b32a )
by Thomas
03:34 queued 01:45
created

FluentFields::numberField()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
ccs 0
cts 4
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 2
1
<?php
2
3
namespace Webfactor\Laravel\Backpack\FluentSyntax\Traits;
4
5
use Webfactor\Laravel\Backpack\FluentSyntax\Contracts\CrudFieldInterface;
6
use Webfactor\Laravel\Backpack\FluentSyntax\Fields\AddressField;
7
use Webfactor\Laravel\Backpack\FluentSyntax\Fields\CheckboxField;
8
use Webfactor\Laravel\Backpack\FluentSyntax\Fields\DatePickerField;
9
use Webfactor\Laravel\Backpack\FluentSyntax\Fields\DateTimePickerField;
10
use Webfactor\Laravel\Backpack\FluentSyntax\Fields\EmailField;
11
use Webfactor\Laravel\Backpack\FluentSyntax\Fields\HiddenField;
12
use Webfactor\Laravel\Backpack\FluentSyntax\Fields\NumberField;
13
use Webfactor\Laravel\Backpack\FluentSyntax\Fields\PasswordField;
14
use Webfactor\Laravel\Backpack\FluentSyntax\Fields\SummernoteField;
15
use Webfactor\Laravel\Backpack\FluentSyntax\Fields\TextareaField;
16
use Webfactor\Laravel\Backpack\FluentSyntax\Fields\TextField;
17
use Webfactor\Laravel\Backpack\FluentSyntax\Fields\UrlField;
18
19
trait FluentFields
20
{
21
    /*
22
    |--------------------------------------------------------------------------
23
    | Methods for providing Fluent Fields
24
    |--------------------------------------------------------------------------
25
    */
26
27
    public function addFields(array $fields)
28
    {
29
        foreach ($fields as $field) {
30
            $this->addField($field);
31
        }
32
    }
33
34
    public function addField(CrudFieldInterface $field)
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
35
    {
36
        return $this->crud->addField($field->make());
0 ignored issues
show
Bug introduced by
The property crud does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
37
    }
38
39
    /*
40
    |--------------------------------------------------------------------------
41
    | Definition of all Field Types
42
    |--------------------------------------------------------------------------
43
    */
44
45
    public function addressField(string $name): AddressField
46
    {
47
        return new AddressField($name);
48
    }
49
50
    public function checkboxField(string $name): CheckboxField
51
    {
52
        return new CheckboxField($name);
53
    }
54
55
    public function datePickerField(string $name): DatePickerField
56
    {
57
        return new DatePickerField($name);
58
    }
59
60
    public function dateTimePickerField(string $name): DateTimePickerField
61
    {
62
        return new DateTimePickerField($name);
63
    }
64
65
    public function emailField(string $name): EmailField
66
    {
67
        return new EmailField($name);
68
    }
69
70
    public function hiddenField(string $name): HiddenField
71
    {
72
        return new HiddenField($name);
73
    }
74
75
    public function numberField(string $name): NumberField
76
    {
77
        return new NumberField($name);
78
    }
79
80
    public function passwordField(string $name): PasswordField
81
    {
82
        return new PasswordField($name);
83
    }
84
85
    public function summernoteField(string $name): SummernoteField
86
    {
87
        return new SummernoteField($name);
88
    }
89
90
    public function textareaField(string $name): TextareaField
91
    {
92
        return new TextareaField($name);
93
    }
94
95
    public function textField(string $name): TextField
96
    {
97
        return new TextField($name);
98
    }
99
100
    public function urlField(string $name): UrlField
101
    {
102
        return new UrlField($name);
103
    }
104
}
105