Passed
Pull Request — master (#1012)
by Diego
03:15
created

OldValueSupportTrait::makeItemValue()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 3
c 1
b 0
f 0
nc 2
nop 2
dl 0
loc 7
ccs 0
cts 4
cp 0
crap 6
rs 10
1
<?php
2
3
namespace JeroenNoten\LaravelAdminLte\Components\Form;
4
5
trait OldValueSupportTrait
6
{
7
    /**
8
     * Enable the retrievement of the submitted value in case of validation
9
     * errors. This submitted value may be automatically shown when there is a
10
     * validation error.
11
     *
12
     * @var bool
13
     */
14
    protected $enableOldSupport;
15
16
    /**
17
     * Make the value attribute for an input item.
18
     *
19
     * @param  string  $errKey  The key name to lookup for validation errors
20
     * @param  mixed  $value  The current value of the item
21
     * @return mixed
22
     */
23
    public function makeItemValue($errorKey, $value = null)
24
    {
25
        if ($this->enableOldSupport) {
26
            $value = old($errorKey, $value);
27
        }
28
29
        return $value;
30
    }
31
}
32