Completed
Push — master ( f55930...e5e2e6 )
by Helmut
03:51
created

Email   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 4
Bugs 0 Features 1
Metric Value
wmc 11
c 4
b 0
f 1
lcom 1
cbo 3
dl 0
loc 50
ccs 20
cts 20
cp 1
rs 10

9 Methods

Rating   Name   Duplication   Size   Complexity  
A getValue() 0 4 1
A getButtonName() 0 4 1
A renderWith() 0 4 1
A setValueFromDefault() 0 4 1
A setValueFromModel() 0 4 2
A setValueFromRequest() 0 4 1
A fillModelWithValue() 0 4 2
A validate() 0 4 1
A validateRequired() 0 4 1
1
<?php 
2
3
namespace Helmut\Forms\Fields\Email;
4
5
use Helmut\Forms\Field;
6
use Helmut\Forms\Utility\Validate;
7
8
class Email extends Field {
9
10
    public $value = '';
11 8
12
    public function getValue()
13 8
    {
14
        return $this->value;
15
    }
16 12
17
    public function getButtonName()
18 12
    {
19
        //
20
    }
21 4
22
    public function renderWith()
23 4
    {
24
        return ['value' => $this->value];
25
    }
26 11
27
    public function setValueFromDefault()
28 11
    {
29 11
        $this->value = $this->default;
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->default of type array is incompatible with the declared type string of property $value.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
30
    }
31 1
32
    public function setValueFromModel($model)
33 1
    {
34 1
        if (property_exists($model, $this->name)) $this->value = $model->{$this->name};
35
    }
36
37
    public function setValueFromRequest($request)
38
    {
39
        $this->value = $request->get($this->name);
40
    }
41 1
42
    public function fillModelWithValue($model)
43 1
    {
44 1
        if (property_exists($model, $this->name)) $model->{$this->name} = $this->value;
45
    }
46 2
47
    public function validate()
48 2
    {
49
        return Validate::email($this->value);
50
    }
51 2
52
    public function validateRequired()
53 2
    {
54
        return Validate::required($this->value);
55
    }
56 3
57
}
58