Completed
Push — master ( 764c30...771e80 )
by wen
03:03
created

Image   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getImageWidth() 0 4 1
A setImageWidth() 0 6 1
A getModelValue() 0 12 3
1
<?php
2
3
4
namespace Sco\Admin\View\Columns;
5
6
class Image extends Column
7
{
8
    protected $template = '<img v-img :width="value.width" :src="value.image" v-if="value.image">';
9
10
    /**
11
     * @var string
12
     */
13
    protected $imageWidth = '80px';
14
15
    /**
16
     * @return string
17
     */
18
    public function getImageWidth()
19
    {
20
        return $this->imageWidth;
21
    }
22
23
    /**
24
     * @param string $width
25
     *
26
     * @return $this
27
     */
28
    public function setImageWidth($width)
29
    {
30
        $this->imageWidth = $width;
31
32
        return $this;
33
    }
34
35
    public function getModelValue()
36
    {
37
        $value = parent::getModelValue();
38
        if (!empty($value) && (strpos($value, '://') === false)) {
39
            $value = asset($value);
40
        }
41
42
        return [
43
            'image' => $value,
44
            'width' => $this->getImageWidth(),
45
        ];
46
    }
47
}
48