Passed
Push — master ( 090acd...539fd4 )
by Florian
03:14
created

OldValueSupportTrait::getOldValue()   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 0
Metric Value
cc 2
eloc 1
nc 2
nop 2
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace JeroenNoten\LaravelAdminLte\View\Components\Form\Traits;
4
5
trait OldValueSupportTrait
6
{
7
    /**
8
     * Whether to enable the retrievement of the submitted value in case of
9
     * validation errors. If enabled, the submitted value will be automatically
10
     * shown when there is a validation error.
11
     *
12
     * @var bool
13
     */
14
    public $enableOldSupport;
15
16
    /**
17
     * Gets the previous submitted value for an input item. When the old value
18
     * support is disabled or the old value can't be found, the specified
19
     * default value is returned.
20
     *
21
     * @param  string  $errorKey  The key to use for look up the old value
22
     * @param  mixed  $default  Default value to use when there isn't old value
23
     * @return mixed
24
     */
25 3
    public function getOldValue($errorKey, $default = null)
26
    {
27 3
        return $this->enableOldSupport ? old($errorKey, $default) : $default;
28
    }
29
}
30