Completed
Push — master ( efa9b4...b05f68 )
by wen
05:55
created

Image::mutateValueAsPath()   A

Complexity

Conditions 3
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 6
ccs 0
cts 6
cp 0
rs 9.4285
cc 3
eloc 3
nc 1
nop 0
crap 12
1
<?php
2
3
namespace Sco\Admin\Form\Elements;
4
5
class Image extends BaseFile
6
{
7
    protected $type = 'image';
8
9
    /**
10
     * {@inheritdoc}
11
     */
12
    public function getValue()
13
    {
14
        $value = parent::getValue();
15
        if (empty($value) || ! $this->existsFile($value)) {
16
            return [];
17
        }
18
19
        return $this->getFileInfo($value);
20
    }
21
22
    protected function mutateValueAsPath()
23
    {
24
        $this->setMutator(function ($value) {
25
            return empty($value) || ! is_array($value) ? '' : $value['path'];
26
        });
27
    }
28
29
    /**
30
     * {@inheritdoc}
31
     */
32
    protected function getDefaultExtensions()
33
    {
34
        return config('admin.upload.extensions.image');
35
    }
36
}
37