OldValueSupportTrait   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 23
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A getOldValue() 0 3 2
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 9
    public function getOldValue($errorKey, $default = null)
26
    {
27 9
        return $this->enableOldSupport ? old($errorKey, $default) : $default;
28
    }
29
}
30