Completed
Push — master ( 650783...0c9838 )
by wen
15:06
created

Image   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 2
dl 0
loc 54
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getImageWidth() 0 4 1
A setImageWidth() 0 6 1
A getValue() 0 12 3
A toArray() 0 9 1
1
<?php
2
3
namespace Sco\Admin\Display\Columns;
4
5
use Sco\Admin\Traits\UploadStorageTrait;
6
7
class Image extends Column
8
{
9
    use UploadStorageTrait;
10
11
    protected $template = '<img v-viewer="column.options" :width="value.width" :src="value.image" v-if="value.image">';
12
13
    /**
14
     * @var string
15
     */
16
    protected $imageWidth = '80px';
17
18
    /**
19
     * @return string
20
     */
21
    public function getImageWidth()
22
    {
23
        return $this->imageWidth;
24
    }
25
26
    /**
27
     * @param string $width
28
     *
29
     * @return $this
30
     */
31
    public function setImageWidth($width)
32
    {
33
        $this->imageWidth = $width;
34
35
        return $this;
36
    }
37
38
    public function getValue()
39
    {
40
        $value = parent::getValue();
41
        if (! empty($value) && (strpos($value, '://') === false)) {
42
            $value = $this->getFileUrl($value);
43
        }
44
45
        return [
46
            'image' => $value,
47
            'width' => $this->getImageWidth(),
48
        ];
49
    }
50
51
    public function toArray()
52
    {
53
        return parent::toArray() + [
54
                'options' => [
55
                    'toolbar' => false,
56
                    'navbar'  => false,
57
                ],
58
            ];
59
    }
60
}
61