JpegStrategy   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 5
eloc 5
c 1
b 0
f 1
dl 0
loc 24
ccs 9
cts 9
cp 1
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 3 1
A save() 0 3 1
A render() 0 3 1
A handleTransparency() 0 2 1
A getContentType() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Del\Image\Strategy;
6
7
use GdImage;
8
9
class JpegStrategy implements ImageTypeStrategyInterface
10
{
11 6
    public function create(string $filename): GdImage
12
    {
13 6
        return \imagecreatefromjpeg($filename);
0 ignored issues
show
Bug Best Practice introduced by
The expression return imagecreatefromjpeg($filename) could return the type resource which is incompatible with the type-hinted return GdImage. Consider adding an additional type-check to rule them out.
Loading history...
14
    }
15
16 1
    public function save(GdImage $resource, string $filename, int $compression): void
17
    {
18 1
        \imagejpeg($resource, $filename, $compression);
19
    }
20
21 1
    public function getContentType(): string
22
    {
23 1
        return 'image/jpeg';
24
    }
25
26 4
    public function render(GdImage $resource): void
27
    {
28 4
        \imagejpeg($resource);
29
    }
30
31 1
    public function handleTransparency(GdImage $newImage, GdImage $image): void
32
    {
33
        // Jpeg's aren't transparent.
34 1
    }
35
}
36