Issues (9)

src/Image/Strategy/PngStrategy.php (1 issue)

1
<?php
2
3
declare(strict_types=1);
4
5
namespace Del\Image\Strategy;
6
7
use GdImage;
8
9
class PngStrategy extends TransparentStrategy implements ImageTypeStrategyInterface
10
{
11 11
    public function create(string $filename): GdImage
12
    {
13 11
        return \imagecreatefrompng($filename);
0 ignored issues
show
Bug Best Practice introduced by
The expression return imagecreatefrompng($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 = 100): void
17
    {
18 1
        \imagepng($resource, $filename);
19
    }
20
21 2
    public function getContentType(): string
22
    {
23 2
        return 'image/png';
24
    }
25
26 8
    public function render(GdImage $resource): void
27
    {
28 8
        \imagealphablending($resource, true);
29 8
        \imagesavealpha($resource, true);
30 8
        \imagepng($resource);
31
    }
32
}
33