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

Image::prepareValue()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
rs 9.4285
cc 3
eloc 4
nc 2
nop 1
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