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

AJenbo / agcms / 21420560247

28 Jan 2026 12:59AM UTC coverage: 52.306% (-1.4%) from 53.72%
21420560247

push

github

AJenbo
Bump phpunit/phpunit from 9.6.11 to 9.6.33 in /application

Bumps [phpunit/phpunit](https://github.com/sebastianbergmann/phpunit) from 9.6.11 to 9.6.33.
- [Release notes](https://github.com/sebastianbergmann/phpunit/releases)
- [Changelog](https://github.com/sebastianbergmann/phpunit/blob/9.6.33/ChangeLog-9.6.md)
- [Commits](https://github.com/sebastianbergmann/phpunit/compare/9.6.11...9.6.33)

---
updated-dependencies:
- dependency-name: phpunit/phpunit
  dependency-version: 9.6.33
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>

3039 of 5810 relevant lines covered (52.31%)

12.21 hits per line

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

0.0
/application/inc/Services/ImageService.php
1
<?php
2

3
namespace App\Services;
4

5
use AJenbo\Image;
6

7
class ImageService
8
{
9
    private Image $image;
10
    private int $cropX = 0;
11
    private int $cropY = 0;
12
    private int $cropW;
13
    private int $cropH;
14
    private bool $autoCrop = false;
15
    private int $maxW;
16
    private int $maxH;
17
    private int $flip = 0;
18
    private int $rotate = 0;
19

20
    /**
21
     * Load the image.
22
     */
23
    public function __construct(string $path)
24
    {
25
        $this->image = new Image($path);
×
26
        $this->cropW = $this->image->getWidth();
×
27
        $this->cropH = $this->image->getHeight();
×
28
        $this->maxW = $this->image->getWidth();
×
29
        $this->maxH = $this->image->getHeight();
×
30
    }
31

32
    /**
33
     * Set cropping operation.
34
     *
35
     * @return $this
36
     */
37
    public function setCrop(int $startX, int $startY, int $width, int $height): self
38
    {
39
        $width = min($this->image->getWidth(), $width);
×
40
        $this->cropW = max(0, $width) ?: $this->image->getWidth();
×
41

42
        $height = min($this->image->getHeight(), $height);
×
43
        $this->cropH = max(0, $height) ?: $this->image->getHeight();
×
44

45
        $startX = $startX + $this->cropW <= $this->image->getWidth() ? $startX : 0;
×
46
        $this->cropX = max(0, $startX);
×
47

48
        $startY = $startY + $this->cropH <= $this->image->getHeight() ? $startY : 0;
×
49
        $this->cropY = max(0, $startY);
×
50

51
        return $this;
×
52
    }
53

54
    /**
55
     * Set autocrop.
56
     *
57
     * @return $this
58
     */
59
    public function setAutoCrop(bool $autoCrop): self
60
    {
61
        $this->autoCrop = $autoCrop;
×
62

63
        return $this;
×
64
    }
65

66
    /**
67
     * Set scale operation.
68
     *
69
     * @return $this
70
     */
71
    public function setScale(int $width, int $height = 0): self
72
    {
73
        $width = min($width, $this->image->getWidth());
×
74
        $this->maxW = max(0, $width) ?: $this->image->getWidth();
×
75

76
        $height = min($height, $this->image->getHeight());
×
77
        $this->maxH = max(0, $height) ?: $this->image->getHeight();
×
78

79
        return $this;
×
80
    }
81

82
    /**
83
     * Set flip/mirror.
84
     *
85
     * @return $this
86
     */
87
    public function setFlip(int $flip): self
88
    {
89
        $this->flip = $flip;
×
90

91
        return $this;
×
92
    }
93

94
    /**
95
     * Set rotate operation.
96
     *
97
     * @return $this
98
     */
99
    public function setRotate(int $rotate): self
100
    {
101
        $this->rotate = $rotate;
×
102

103
        return $this;
×
104
    }
105

106
    /**
107
     * Test if the settings will cause a change in the image.
108
     */
109
    public function isNoOp(): bool
110
    {
111
        if ($this->cropW !== $this->image->getWidth() || $this->cropH !== $this->image->getHeight()) {
×
112
            return false;
×
113
        }
114

115
        if ($this->autoCrop) {
×
116
            $content = $this->image->findContent();
×
117
            if ($content['width'] !== $this->image->getWidth() || $content['height'] !== $this->image->getHeight()) {
×
118
                return false;
×
119
            }
120
        }
121

122
        if ($this->maxW !== $this->image->getWidth() || $this->maxH !== $this->image->getHeight()) {
×
123
            return false;
×
124
        }
125

126
        return !$this->flip && !$this->rotate;
×
127
    }
128

129
    /**
130
     * Get image width.
131
     */
132
    public function getWidth(): int
133
    {
134
        return $this->image->getWidth();
×
135
    }
136

137
    /**
138
     * Get image height.
139
     */
140
    public function getHeight(): int
141
    {
142
        return $this->image->getHeight();
×
143
    }
144

145
    /**
146
     * Performe the set operations and save the image.
147
     *
148
     * Doing so will reset the changes
149
     */
150
    public function processImage(string $targetPath, string $type = 'jpeg'): void
151
    {
152
        $this->image->crop($this->cropX, $this->cropY, $this->cropW, $this->cropH);
×
153

154
        if ($this->autoCrop) {
×
155
            $this->autoCrop();
×
156
        }
157

158
        $this->image->resize($this->maxW, $this->maxH);
×
159

160
        if ($this->flip) {
×
161
            // Flip / mirror
162
            $this->image->flip(1 === $this->flip ? 'x' : 'y');
×
163
        }
164

165
        $this->image->rotate($this->rotate);
×
166

167
        $this->image->save($targetPath, $type);
×
168
        $this->reset();
×
169
    }
170

171
    /**
172
     * Trim image whitespace.
173
     */
174
    private function autoCrop(): void
175
    {
176
        $imageContent = $this->image->findContent();
×
177

178
        $this->maxW = min($this->maxW, $imageContent['width']);
×
179
        $this->maxH = min($this->maxH, $imageContent['height']);
×
180

181
        $this->image->crop(
×
182
            $imageContent['x'],
×
183
            $imageContent['y'],
×
184
            $imageContent['width'],
×
185
            $imageContent['height']
×
186
        );
×
187
    }
188

189
    /**
190
     * Reset operations to loaded image.
191
     */
192
    private function reset(): void
193
    {
194
        $this->cropX = 0;
×
195
        $this->cropY = 0;
×
196
        $this->cropW = $this->image->getWidth();
×
197
        $this->cropH = $this->image->getHeight();
×
198

199
        $this->autoCrop = false;
×
200

201
        $this->maxW = $this->image->getWidth();
×
202
        $this->maxH = $this->image->getHeight();
×
203

204
        $this->flip = 0;
×
205
        $this->rotate = 0;
×
206
    }
207
}
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