Skip to content

Commit b599206

Browse files
committed
Rename hasMimeType to isType in MimeType class
Refactored the MimeType value object by renaming the hasMimeType method to isType for improved clarity. Updated all internal usages and corresponding unit tests to use the new method name.
1 parent 75f07f2 commit b599206

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/Files/ValueObjects/MimeType.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ public static function isValid(string $mimeType): bool
179179
* @param string $mimeType The MIME type to check.
180180
* @return bool True if the MIME type has the specified MIME type.
181181
*/
182-
public function hasMimeType(string $mimeType): bool
182+
public function isType(string $mimeType): bool
183183
{
184184
return strpos($this->value, $mimeType . '/') === 0;
185185
}
@@ -193,7 +193,7 @@ public function hasMimeType(string $mimeType): bool
193193
*/
194194
public function isImage(): bool
195195
{
196-
return $this->hasMimeType('image');
196+
return $this->isType('image');
197197
}
198198

199199
/**
@@ -205,7 +205,7 @@ public function isImage(): bool
205205
*/
206206
public function isAudio(): bool
207207
{
208-
return $this->hasMimeType('audio');
208+
return $this->isType('audio');
209209
}
210210

211211
/**
@@ -217,7 +217,7 @@ public function isAudio(): bool
217217
*/
218218
public function isVideo(): bool
219219
{
220-
return $this->hasMimeType('video');
220+
return $this->isType('video');
221221
}
222222

223223
/**
@@ -229,7 +229,7 @@ public function isVideo(): bool
229229
*/
230230
public function isText(): bool
231231
{
232-
return $this->hasMimeType('text');
232+
return $this->isType('text');
233233
}
234234

235235
/**

tests/unit/Files/ValueObjects/MimeTypeTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -288,10 +288,10 @@ public function testHasMimeType(): void
288288
$mimeType = new MimeType('image/jpeg');
289289
$fontType = new MimeType('font/ttf');
290290

291-
$this->assertTrue($mimeType->hasMimeType('image'));
292-
$this->assertFalse($mimeType->hasMimeType('video'));
291+
$this->assertTrue($mimeType->isType('image'));
292+
$this->assertFalse($mimeType->isType('video'));
293293

294-
$this->assertTrue($fontType->hasMimeType('font'));
295-
$this->assertFalse($fontType->hasMimeType('image'));
294+
$this->assertTrue($fontType->isType('font'));
295+
$this->assertFalse($fontType->isType('image'));
296296
}
297297
}

0 commit comments

Comments
 (0)