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

Image   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 7
c 2
b 0
f 0
lcom 0
cbo 1
dl 0
loc 32
ccs 0
cts 18
cp 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getValue() 0 9 3
A mutateValueAsPath() 0 6 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
    /**
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