Completed
Push — master ( 85c58c...2c5e88 )
by wen
10:27
created

Image::getValue()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

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