Image::setImageWidth()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 6
ccs 0
cts 5
cp 0
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
crap 2
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 $type = '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 View Code Duplication
        if (! empty($value) && (strpos($value, '://') === false)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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