Completed
Push — master ( f066c0...72d72a )
by Yaro
01:50 queued 10s
created

RepeaterFile::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 2
1
<?php
2
3
namespace Yaro\Jarboe\Table\Fields\Adapters;
4
5
use Illuminate\Http\Request;
6
use Yaro\Jarboe\Table\Fields\File;
7
8
class RepeaterFile
9
{
10
    /**
11
     * @var File
12
     */
13
    private $field;
14
15
    public function __construct(File $field)
16
    {
17
        $this->field = $field;
18
    }
19
20
    public function value(Request $request)
21
    {
22
        $paths = $this->field->value($request);
23
        if (!$paths) {
24
            $defaultValue = $this->isMultiple() ? [] : '';
25
            $value = $request->get($this->name(), $defaultValue);
26
27
            return !$value && $this->isNullable() ? null : $value;
28
        }
29
30
        return $paths;
31
    }
32
33
    public function __call($method, $parameters)
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
34
    {
35
        return $this->field->$method(...$parameters);
36
    }
37
}
38