EmailFieldType::getOptionsForm()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 4
Ratio 100 %

Importance

Changes 0
Metric Value
dl 4
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Hechoenlaravel\JarvisFoundation\Field\Email;
4
5
use Field;
6
use Hechoenlaravel\JarvisFoundation\Field\FieldTypeInterface;
7
use Hechoenlaravel\JarvisFoundation\Field\FieldTypeImplementationTrait;
8
9
/**
10
 * Class EmailFieldType
11
 * @package Hechoenlaravel\JarvisFoundation\Field\Email
12
 */
13 View Code Duplication
class EmailFieldType implements FieldTypeInterface
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
14
{
15
    use FieldTypeImplementationTrait;
16
17
    /**
18
     * @var
19
     */
20
    private $value;
21
22
    /**
23
     * @var string
24
     */
25
    protected $columnType = "string";
26
27
    /**
28
     * The field type name
29
     * @var string
30
     */
31
    public $name = "Email";
32
33
    /**
34
     * get the column type for this field type
35
     * @return string
36
     */
37
    public function getColumnType()
38
    {
39
        return $this->columnType;
40
    }
41
42
    /**
43
     * Set a value for this field;
44
     * @param $value
45
     */
46
    public function setValue($value)
47
    {
48
        $this->value = $value;
49
    }
50
51
52
    /**
53
     * get the value for the field
54
     * @return mixed
55
     */
56
    public function getValue()
57
    {
58
        return $this->value;
59
    }
60
61
    /**
62
     * Get the presenter class if any
63
     * @return mixed
64
     */
65
    public function present()
66
    {
67
        return Field::email($this->fieldSlug, $this->value, ['label' => $this->fieldName]);
0 ignored issues
show
Bug introduced by
The property fieldSlug 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...
Bug introduced by
The property fieldName 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...
68
    }
69
70
    /**
71
     * Que the form for the options of the field type
72
     * @return mixed
73
     */
74
    public function getOptionsForm()
75
    {
76
        return view('jarvisPlatform::field.types.email.optionsForm')->render();
0 ignored issues
show
Bug introduced by
The method render() does not seem to exist on object<BladeView>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
77
    }
78
79
    /**
80
     * @return mixed
81
     */
82
    public function presentFront()
83
    {
84
        return $this->value;
85
    }
86
}
87