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

Image   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 7
c 1
b 0
f 0
lcom 1
cbo 1
dl 0
loc 28
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getValue() 0 9 3
A prepareValue() 0 8 3
A getDefaultExtensions() 0 4 1
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