Passed
Push — master ( 9925c8...02f327 )
by Thomas
03:39 queued 01:47
created

FluentFields::emailField()   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\ColorPickerField;
9
use Webfactor\Laravel\Backpack\FluentSyntax\Fields\DatePickerField;
10
use Webfactor\Laravel\Backpack\FluentSyntax\Fields\DateRangeField;
11
use Webfactor\Laravel\Backpack\FluentSyntax\Fields\DateTimePickerField;
12
use Webfactor\Laravel\Backpack\FluentSyntax\Fields\EmailField;
13
use Webfactor\Laravel\Backpack\FluentSyntax\Fields\EnumField;
14
use Webfactor\Laravel\Backpack\FluentSyntax\Fields\HiddenField;
15
use Webfactor\Laravel\Backpack\FluentSyntax\Fields\IconPickerField;
16
use Webfactor\Laravel\Backpack\FluentSyntax\Fields\ImageField;
17
use Webfactor\Laravel\Backpack\FluentSyntax\Fields\NumberField;
18
use Webfactor\Laravel\Backpack\FluentSyntax\Fields\PasswordField;
19
use Webfactor\Laravel\Backpack\FluentSyntax\Fields\SummernoteField;
20
use Webfactor\Laravel\Backpack\FluentSyntax\Fields\TextareaField;
21
use Webfactor\Laravel\Backpack\FluentSyntax\Fields\TextField;
22
use Webfactor\Laravel\Backpack\FluentSyntax\Fields\UrlField;
23
24
trait FluentFields
25
{
26
    /*
27
    |--------------------------------------------------------------------------
28
    | Methods for providing Fluent Fields
29
    |--------------------------------------------------------------------------
30
    */
31
32
    public function addFields(array $fields)
33
    {
34
        foreach ($fields as $field) {
35
            $this->addField($field);
36
        }
37
    }
38
39
    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...
40
    {
41
        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...
42
    }
43
44
    /*
45
    |--------------------------------------------------------------------------
46
    | Definition of all Field Types
47
    |--------------------------------------------------------------------------
48
    */
49
50
    public function addressField(string $name): AddressField
51
    {
52
        return new AddressField($name);
53
    }
54
55
    public function checkboxField(string $name): CheckboxField
56
    {
57
        return new CheckboxField($name);
58
    }
59
60
    public function colorPickerField(string $name): ColorPickerField
61
    {
62
        return new ColorPickerField($name);
63
    }
64
65
    public function datePickerField(string $name): DatePickerField
66
    {
67
        return new DatePickerField($name);
68
    }
69
70
    public function dateRangeField(string $uniqueName, string $startColumn, string $endColumn): DateRangeField
71
    {
72
        return new DateRangeField($uniqueName, $startColumn, $endColumn);
73
    }
74
75
    public function dateTimePickerField(string $name): DateTimePickerField
76
    {
77
        return new DateTimePickerField($name);
78
    }
79
80
    public function emailField(string $name): EmailField
81
    {
82
        return new EmailField($name);
83
    }
84
85
    public function enumField(string $name): EnumField
86
    {
87
        return new EnumField($name);
88
    }
89
90
    public function hiddenField(string $name): HiddenField
91
    {
92
        return new HiddenField($name);
93
    }
94
95
    public function iconPickerField(string $name): IconPickerField
96
    {
97
        return new IconPickerField($name);
98
    }
99
100
    public function ImageField(string $name): ImageField
0 ignored issues
show
Coding Style introduced by
This method is not in camel caps format.

This check looks for method names that are not written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection seeker becomes databaseConnectionSeeker.

Loading history...
101
    {
102
        return new ImageField($name);
103
    }
104
105
    public function numberField(string $name): NumberField
106
    {
107
        return new NumberField($name);
108
    }
109
110
    public function passwordField(string $name): PasswordField
111
    {
112
        return new PasswordField($name);
113
    }
114
115
    public function summernoteField(string $name): SummernoteField
116
    {
117
        return new SummernoteField($name);
118
    }
119
120
    public function textareaField(string $name): TextareaField
121
    {
122
        return new TextareaField($name);
123
    }
124
125
    public function textField(string $name): TextField
126
    {
127
        return new TextField($name);
128
    }
129
130
    public function urlField(string $name): UrlField
131
    {
132
        return new UrlField($name);
133
    }
134
}
135