• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

68publishers / image-storage / 20785308562

07 Jan 2026 02:46PM UTC coverage: 91.321% (-0.6%) from 91.908%
20785308562

push

github

tg666
Fixed unit test `StripMetaTest` for PHP 8.1

1389 of 1521 relevant lines covered (91.32%)

0.91 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

70.83
/src/Resource/ImageResource.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace SixtyEightPublishers\ImageStorage\Resource;
6

7
use Intervention\Image\Image;
8
use SixtyEightPublishers\FileStorage\PathInfoInterface;
9
use SixtyEightPublishers\ImageStorage\Modifier\Facade\ModifierFacadeInterface;
10

11
class ImageResource implements ResourceInterface
12
{
13
    private bool $modified = false;
14

15
    private ?string $encodeFormat = null;
16

17
    private ?int $encodeQuality = null;
18

19
    public function __construct(
1✔
20
        private PathInfoInterface $pathInfo,
21
        private Image $image,
22
        private readonly string $localFilename,
23
        private readonly ModifierFacadeInterface $modifierFacade,
24
    ) {}
1✔
25

26
    public function getPathInfo(): PathInfoInterface
27
    {
28
        return $this->pathInfo;
1✔
29
    }
30

31
    public function getSource(): Image
32
    {
33
        return $this->image;
1✔
34
    }
35

36
    public function getLocalFilename(): string
37
    {
38
        return $this->localFilename;
1✔
39
    }
40

41
    public function hasBeenModified(): bool
42
    {
43
        return $this->modified;
1✔
44
    }
45

46
    public function withPathInfo(PathInfoInterface $pathInfo): self
47
    {
48
        $resource = clone $this;
1✔
49
        $resource->pathInfo = $pathInfo;
1✔
50

51
        return $resource;
1✔
52
    }
53

54
    public function modifyImage(string|array $modifiers, bool $stripMeta = false): self
55
    {
56
        $resource = clone $this;
1✔
57
        $modifyResult = $this->modifierFacade->modifyImage($this->image, $this->pathInfo, $modifiers, $stripMeta);
1✔
58
        $resource->image = $modifyResult->image;
1✔
59

60
        if ($modifyResult->modified) {
1✔
61
            $resource->modified = $modifyResult->modified;
1✔
62
        }
63

64
        if (null !== $modifyResult->encodeFormat) {
1✔
65
            $resource->encodeFormat = $modifyResult->encodeFormat;
×
66
        }
67

68
        if (null !== $modifyResult->encodeQuality) {
1✔
69
            $resource->encodeQuality = $modifyResult->encodeQuality;
×
70
        }
71

72
        return $resource;
1✔
73
    }
74

75
    public function getMimeType(): ?string
76
    {
77
        return $this->image->mime();
×
78
    }
79

80
    public function getFilesize(): ?int
81
    {
82
        $filesize = null !== $this->image->basePath() ? $this->image->filesize() : false; # @phpstan-ignore-line ternary.alwaysTrue
×
83

84
        return false !== $filesize ? (int) $filesize : null;
×
85
    }
86

87
    public function getEncodeQuality(): ?int
88
    {
89
        return $this->encodeQuality;
×
90
    }
91

92
    public function getEncodeFormat(): ?string
93
    {
94
        return $this->encodeFormat;
×
95
    }
96
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc