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

tito10047 / progressive-image-bundle / 20661725623

02 Jan 2026 04:11PM UTC coverage: 89.065%. Remained the same
20661725623

push

github

tito10047
replace `grid` with `sizes`: update all references in templates, tests, and documentation to align with the new attribute name; adjust `Image` component logic accordingly and ensure backward compatibility

1 of 1 new or added line in 1 file covered. (100.0%)

111 existing lines in 9 files now uncovered.

562 of 631 relevant lines covered (89.06%)

166.02 hits per line

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

96.77
/src/Service/LiipImagineRuntimeConfigGenerator.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace Tito10047\ProgressiveImageBundle\Service;
6

7
use Liip\ImagineBundle\Exception\Imagine\Filter\NonExistingFilterException;
8
use Liip\ImagineBundle\Imagine\Filter\FilterConfiguration;
9

10
class LiipImagineRuntimeConfigGenerator
11
{
12
        public function __construct(
13
                private readonly FilterConfiguration $filterConfiguration,
14
        ) {
UNCOV
15
        }
322✔
16

17
        /**
18
         * @return array{filterName: string, config: array<string, mixed>}
19
         */
20
        public function generate(int $width, int $height, ?string $filter = null, ?string $pointInterest = null, ?int $origWidth = null, ?int $origHeight = null): array
21
        {
UNCOV
22
                $filterName = $filter ? sprintf('%s_%dx%d', $filter, $width, $height) : sprintf('%dx%d', $width, $height);
210✔
23

UNCOV
24
                if ($pointInterest) {
210✔
UNCOV
25
                        $filterName .= '_' . $pointInterest;
56✔
26
                }
27

UNCOV
28
                $config = [];
210✔
UNCOV
29
                if ($filter !== null) {
210✔
30
                        try {
UNCOV
31
                                $config = $this->filterConfiguration->get($filter);
28✔
32
                        } catch (NonExistingFilterException) {
×
33
                        }
34
                }
35

UNCOV
36
                if (!isset($config['filters'])) {
210✔
UNCOV
37
                        $config['filters'] = [];
182✔
38
                }
39

UNCOV
40
                if ($pointInterest && $origWidth && $origHeight) {
210✔
UNCOV
41
                        [$poiX, $poiY] = explode('x', $pointInterest);
56✔
UNCOV
42
                        $config['filters']['crop'] = [
56✔
UNCOV
43
                                'start' => $this->calculateCropStart((int)$poiX, (int)$poiY, $width, $height, $origWidth, $origHeight),
56✔
UNCOV
44
                                'size' => [$width, $height],
56✔
UNCOV
45
                        ];
56✔
46
                }
47

UNCOV
48
                $config['filters']['thumbnail'] = [
210✔
UNCOV
49
                        'size' => [$width, $height],
210✔
UNCOV
50
                        'mode' => 'outbound',
210✔
UNCOV
51
                ];
210✔
52

UNCOV
53
                return [
210✔
UNCOV
54
                        'filterName' => $filterName,
210✔
UNCOV
55
                        'config' => $config,
210✔
UNCOV
56
                ];
210✔
57
        }
58

59
        /**
60
         * @return array{int, int}
61
         */
62
        private function calculateCropStart(int $poiX, int $poiY, int $targetWidth, int $targetHeight, int $origWidth, int $origHeight): array
63
        {
64
                // 1. Vypočítame stred orezu na originálnom obrázku podľa percentuálneho bodu záujmu
UNCOV
65
                $centerX = (int) ($poiX / 100 * $origWidth);
56✔
UNCOV
66
                $centerY = (int) ($poiY / 100 * $origHeight);
56✔
67

68
                // 2. Vypočítame začiatok orezu tak, aby stred bol na bode záujmu
UNCOV
69
                $startX = $centerX - (int) ($targetWidth / 2);
56✔
UNCOV
70
                $startY = $centerY - (int) ($targetHeight / 2);
56✔
71

72
                // 3. Zabezpečíme, aby orez nevychádzal mimo originálny obrázok
UNCOV
73
                $startX = max(0, min($startX, $origWidth - $targetWidth));
56✔
UNCOV
74
                $startY = max(0, min($startY, $origHeight - $targetHeight));
56✔
75

UNCOV
76
                return [$startX, $startY];
56✔
77
        }
78
}
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