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

nepada / file-upload-control / 11552144244

28 Oct 2024 10:34AM UTC coverage: 81.633% (-8.7%) from 90.293%
11552144244

push

github

xificurk
Cleanup imported code

12 of 31 new or added lines in 3 files covered. (38.71%)

32 existing lines in 2 files now uncovered.

720 of 882 relevant lines covered (81.63%)

0.82 hits per line

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

78.13
/src/FileUploadControl/Thumbnail/ImageLoader.php
1
<?php
2
declare(strict_types = 1);
3

4
namespace Nepada\FileUploadControl\Thumbnail;
5

6
use Nette;
7
use Nette\Utils\Image;
8
use Nette\Utils\ImageColor;
9

10
final class ImageLoader
11
{
12

13
    use Nette\SmartObject;
14

15
    private bool $autoRotate;
16

17
    public function __construct(bool $autoRotate = true)
1✔
18
    {
19
        $this->autoRotate = $autoRotate;
1✔
20
    }
1✔
21

22
    public function load(string $path): Image
1✔
23
    {
24
        $image = Image::fromFile($path);
1✔
25
        if (! $this->autoRotate) {
1✔
26
            return $image;
1✔
27
        }
28

29
        $exifData = @exif_read_data($path);
1✔
30
        if ($exifData === false) {
1✔
31
            return $image;
1✔
32
        }
33

34
        $orientation = $exifData['Orientation'] ?? 1;
1✔
35
        switch ($orientation) {
1✔
UNCOV
36
            case 2:
×
37
                $image->resize('-100%', null);
1✔
38
                break;
1✔
UNCOV
39
            case 3:
×
40
                $image->resize('-100%', '-100%');
1✔
41
                break;
1✔
UNCOV
42
            case 4:
×
43
                $image->resize(null, '-100%');
1✔
44
                break;
1✔
45
            /** @noinspection PhpMissingBreakStatementInspection */
UNCOV
46
            case 5:
×
47
                $image->resize(null, '-100%');
1✔
48
                // intentionally no break
UNCOV
49
            case 6:
×
50
                $image->rotate(-90, ImageColor::rgb(0, 0, 0, 0));
1✔
51
                break;
1✔
52
            /** @noinspection PhpMissingBreakStatementInspection */
UNCOV
53
            case 7:
×
54
                $image->resize(null, '-100%');
1✔
55
                // intentionally no break
UNCOV
56
            case 8:
×
57
                $image->rotate(90, ImageColor::rgb(0, 0, 0, 0));
1✔
58
                break;
1✔
59
        }
60

61
        return $image;
1✔
62
    }
63

64
}
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