Passed
Push — develop ( 5338a4...74435c )
by Richard
02:48
created

StoryblokSvg   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
eloc 14
c 1
b 0
f 0
dl 0
loc 46
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A extractMetaDetails() 0 11 1
A assetDomain() 0 5 1
A resize() 0 3 1
A format() 0 3 1
A buildUrl() 0 2 1
A fitIn() 0 3 1
1
<?php
2
3
namespace Riclep\Storyblok\Support\ImageTransformers;
4
5
use Illuminate\Support\Str;
6
7
class StoryblokSvg extends BaseTransformer
8
{
9
    public function buildUrl(): string {
10
        return $this->assetDomain();
11
    }
12
13
    protected function extractMetaDetails(): void
14
    {
15
        $path = $this->image->content()['filename'];
16
17
        preg_match_all('/(?<width>\d+)x(?<height>\d+).+\.(?<extension>[a-z]{3,4})/mi', $path, $dimensions, PREG_SET_ORDER, 0);
18
19
        $this->meta = [
20
            'height' => null,
21
            'width' => null,
22
            'extension' => 'svg',
23
            'mime' => 'image/svg+xml',
24
        ];
25
    }
26
27
    public function resize(int $width, int $height = null): static
0 ignored issues
show
Unused Code introduced by
The parameter $width is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

27
    public function resize(/** @scrutinizer ignore-unused */ int $width, int $height = null): static

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $height is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

27
    public function resize(int $width, /** @scrutinizer ignore-unused */ int $height = null): static

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
28
    {
29
        return $this;
30
    }
31
32
    public function fitIn(int $width = 0, int $height = 0, string $fill = 'transparent'): static
0 ignored issues
show
Unused Code introduced by
The parameter $width is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

32
    public function fitIn(/** @scrutinizer ignore-unused */ int $width = 0, int $height = 0, string $fill = 'transparent'): static

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $height is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

32
    public function fitIn(int $width = 0, /** @scrutinizer ignore-unused */ int $height = 0, string $fill = 'transparent'): static

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $fill is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

32
    public function fitIn(int $width = 0, int $height = 0, /** @scrutinizer ignore-unused */ string $fill = 'transparent'): static

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
33
    {
34
        return $this;
35
    }
36
37
    public function format(string $format, int $quality = null): static
0 ignored issues
show
Unused Code introduced by
The parameter $format is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

37
    public function format(/** @scrutinizer ignore-unused */ string $format, int $quality = null): static

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $quality is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

37
    public function format(string $format, /** @scrutinizer ignore-unused */ int $quality = null): static

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
38
    {
39
        return $this;
40
    }
41
42
    /**
43
     * Sets the asset domain
44
     *
45
     * @param $options
46
     * @return string
47
     */
48
    protected function assetDomain($options = null): string
0 ignored issues
show
Unused Code introduced by
The parameter $options is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

48
    protected function assetDomain(/** @scrutinizer ignore-unused */ $options = null): string

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
49
    {
50
        $resource = str_replace(config('storyblok.asset_domain'), config('storyblok.image_service_domain'), $this->image->content()['filename']);
51
52
        return $resource;
53
    }
54
}
55