Completed
Push — master ( d68ab4...0c873a )
by Anılcan
01:29
created

Form::setModel()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace AnilcanCakir\Former;
4
5
use AnilcanCakir\Former\Contracts\Form\Factory;
6
use AnilcanCakir\Former\Fields\Field;
7
use Illuminate\Database\Eloquent\Model;
8
9
class Form
10
{
11
    /**
12
     * The form fields.
13
     *
14
     * @var Field[]
15
     */
16
    protected $fields = [];
17
18
    /**
19
     * The form model.
20
     *
21
     * @var Model
22
     */
23
    protected $model;
24
25
    /**
26
     * Get the model fields.
27
     *
28
     * @return Field[]
29
     */
30
    public function getFields(): array
31
    {
32
        return $this->fields;
33
    }
34
35
    /**
36
     * Set the model fields.
37
     *
38
     * @param $name
39
     * @param array $rules
40
     */
41
    public function addField($name, array $rules)
0 ignored issues
show
Unused Code introduced by
The parameter $name is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $rules is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
42
    {
43
        $field = new Field();
0 ignored issues
show
Bug introduced by
The call to Field::__construct() misses a required argument $translator.

This check looks for function calls that miss required arguments.

Loading history...
Unused Code introduced by
$field is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
44
    }
45
46
    /**
47
     * Get the form model.
48
     *
49
     * @return Model
50
     */
51
    public function getModel(): Model
52
    {
53
        return $this->model;
54
    }
55
56
    /**
57
     * Set the form model.
58
     *
59
     * @param Model $model
60
     */
61
    public function setModel(Model $model)
62
    {
63
        $this->model = $model;
64
    }
65
}