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

68publishers / image-storage / 10120426966

27 Jul 2024 03:14AM UTC coverage: 92.95% (+0.2%) from 92.757%
10120426966

push

github

tg666
Fixed PHPStan

1503 of 1617 relevant lines covered (92.95%)

0.93 hits per line

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

84.21
/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
    public function __construct(
1✔
16
        private PathInfoInterface $pathInfo,
17
        private Image $image,
18
        private readonly string $localFilename,
19
        private readonly ModifierFacadeInterface $modifierFacade,
20
    ) {}
1✔
21

22
    public function getPathInfo(): PathInfoInterface
23
    {
24
        return $this->pathInfo;
1✔
25
    }
26

27
    public function getSource(): Image
28
    {
29
        return $this->image;
1✔
30
    }
31

32
    public function getLocalFilename(): string
33
    {
34
        return $this->localFilename;
1✔
35
    }
36

37
    public function hasBeenModified(): bool
38
    {
39
        return $this->modified;
1✔
40
    }
41

42
    public function withPathInfo(PathInfoInterface $pathInfo): self
1✔
43
    {
44
        $resource = clone $this;
1✔
45
        $resource->pathInfo = $pathInfo;
1✔
46

47
        return $resource;
1✔
48
    }
49

50
    public function modifyImage(string|array $modifiers): self
1✔
51
    {
52
        $resource = clone $this;
1✔
53
        $modifyResult = $this->modifierFacade->modifyImage($this->image, $this->pathInfo, $modifiers);
1✔
54
        $resource->image = $modifyResult->image;
1✔
55
        $resource->modified = $modifyResult->modified;
1✔
56

57
        return $resource;
1✔
58
    }
59

60
    public function getMimeType(): ?string
61
    {
62
        return $this->image->mime();
×
63
    }
64

65
    public function getFilesize(): ?int
66
    {
67
        $filesize = null !== $this->image->basePath() ? $this->image->filesize() : false; # @phpstan-ignore-line ternary.alwaysTrue
×
68

69
        return false !== $filesize ? (int) $filesize : null;
×
70
    }
71
}
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

© 2025 Coveralls, Inc