Passed
Push — master ( 7ffe4a...d86acf )
by Florian
03:03
created

OldValueSupportTrait::makeItemValue()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 1
c 1
b 0
f 0
nc 2
nop 2
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 2
rs 10
1
<?php
2
3
namespace JeroenNoten\LaravelAdminLte\Components\Form\Traits;
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, with auto lookup for a
18
     * submitted value in case of validation errors.
19
     *
20
     * @param  string  $errorKey  The key name to lookup for validation errors
21
     * @param  mixed  $default  The default value for the input element
22
     * @return mixed
23
     */
24 2
    public function makeItemValue($errorKey, $default = null)
25
    {
26 2
        return $this->enableOldSupport ? old($errorKey, $default) : $default;
27
    }
28
}
29