Completed
Pull Request — master (#1350)
by
unknown
03:06
created

PlainInput::prependIcon()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 2
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Encore\Admin\Form\Field;
4
5
trait PlainInput
6
{
7
    protected $prepend;
8
9
    protected $append;
10
11
    public function prependIcon($icon, $class = "")
12
    {
13
        if (is_null($this->prepend)) {
14
            $this->prepend = '<i class="fa fa-' . $icon . " " . $class . '"></i>';
15
        }
16
17
        return $this;
18
    }
19
20
    public function appendIcon($icon, $class = "")
21
    {
22
        if (is_null($this->append)) {
23
            $this->append = '<i class="fa fa-' . $icon . " " . $class . '"></i>';
24
        }
25
26
        return $this;
27
    }
28
29
    public function prepend($string)
30
    {
31
        if (is_null($this->prepend)) {
32
            $this->prepend = $string;
33
        }
34
35
        return $this;
36
    }
37
38
    public function append($string)
39
    {
40
        if (is_null($this->append)) {
41
            $this->append = $string;
42
        }
43
44
        return $this;
45
    }
46
47
    protected function initPlainInput()
48
    {
49
        if (empty($this->view)) {
50
            $this->view = 'admin::form.input';
0 ignored issues
show
Bug introduced by
The property view 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...
51
        }
52
    }
53
54
    protected function defaultAttribute($attribute, $value)
55
    {
56
        if (!array_key_exists($attribute, $this->attributes)) {
0 ignored issues
show
Bug introduced by
The property attributes 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...
57
            $this->attribute($attribute, $value);
0 ignored issues
show
Bug introduced by
The method attribute() does not exist on Encore\Admin\Form\Field\PlainInput. Did you maybe mean defaultAttribute()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
58
        }
59
60
        return $this;
61
    }
62
}
63