@@ -128,11 +128,11 @@ public function setInstance(GdImage $instance) : static
128128 public function getQuality () : ?int
129129 {
130130 if ($ this ->quality === null ) {
131- if ($ this ->getType () === \IMAGETYPE_PNG ) {
131+ if ($ this ->isType ( \IMAGETYPE_PNG ) ) {
132132 $ this ->quality = 6 ;
133- } elseif ($ this ->getType () === \IMAGETYPE_JPEG ) {
133+ } elseif ($ this ->isType ( \IMAGETYPE_JPEG ) ) {
134134 $ this ->quality = 75 ;
135- } elseif ($ this ->getType () === \IMAGETYPE_AVIF ) {
135+ } elseif ($ this ->isType ( \IMAGETYPE_AVIF ) ) {
136136 $ this ->quality = 52 ;
137137 }
138138 }
@@ -154,22 +154,22 @@ public function getQuality() : ?int
154154 */
155155 public function setQuality (int $ quality ) : static
156156 {
157- if ($ this ->getType () === \IMAGETYPE_GIF ) {
157+ if ($ this ->isType ( \IMAGETYPE_GIF ) ) {
158158 throw new LogicException (
159159 'GIF images does not receive a quality value '
160160 );
161161 }
162- if ($ this ->getType () === \IMAGETYPE_PNG && ($ quality < 0 || $ quality > 9 )) {
162+ if ($ this ->isType ( \IMAGETYPE_PNG ) && ($ quality < 0 || $ quality > 9 )) {
163163 throw new InvalidArgumentException (
164164 'PNG images must receive a quality value between 0 and 9, ' . $ quality . ' given '
165165 );
166166 }
167- if ($ this ->getType () === \IMAGETYPE_JPEG && ($ quality < 0 || $ quality > 100 )) {
167+ if ($ this ->isType ( \IMAGETYPE_JPEG ) && ($ quality < 0 || $ quality > 100 )) {
168168 throw new InvalidArgumentException (
169169 'JPEG images must receive a quality value between 0 and 100, ' . $ quality . ' given '
170170 );
171171 }
172- if ($ this ->getType () === \IMAGETYPE_AVIF && ($ quality < 0 || $ quality > 100 )) {
172+ if ($ this ->isType ( \IMAGETYPE_AVIF ) && ($ quality < 0 || $ quality > 100 )) {
173173 throw new InvalidArgumentException (
174174 'AVIF images must receive a quality value between 0 and 100, ' . $ quality . ' given '
175175 );
@@ -286,6 +286,11 @@ protected function setType(int $type) : static
286286 return $ this ;
287287 }
288288
289+ public function isType (int $ type ) : bool
290+ {
291+ return $ this ->getType () === $ type ;
292+ }
293+
289294 /**
290295 * Creates a new Image based in the current instance.
291296 *
0 commit comments