Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
# Conflicts:
#	.cs.php
#	.github/workflows/build.yml
#	README.md
#	composer.json
#	phpstan.neon
#	src/Detector/JpegDetector.php
#	src/Detector/PbmDetector.php
#	src/Detector/PsdDetector.php
#	tests/ImageTypeDetectorTest.php
  • Loading branch information
odan committed Sep 9, 2023
2 parents e19c256 + 1012302 commit ccb8048
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 16 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
/tests export-ignore
/build export-ignore
/docs export-ignore
/.github export-ignore
/build.xml export-ignore
/phpunit.xml export-ignore
/.gitattributes export-ignore
Expand Down
5 changes: 4 additions & 1 deletion src/Detector/AniDetector.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ public function detect(SplFileObject $file): ?ImageType
$file->fread(4);
$aniSignature = $file->fread(4);

return $riffSignature === 'RIFF' && $aniSignature === 'ACON' ? new ImageType(ImageFormat::ANI, MimeType::APPLICATION_X_NAVI_ANIMATION) : null;
return $riffSignature === 'RIFF' && $aniSignature === 'ACON' ? new ImageType(
ImageFormat::ANI,
MimeType::APPLICATION_X_NAVI_ANIMATION
) : null;
}
}
5 changes: 4 additions & 1 deletion src/Detector/CineonDetector.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ public function detect(SplFileObject $file): ?ImageType
{
$bytes = bin2hex((string)$file->fread(4));

return $bytes === '802a5fd7' || $bytes === 'd75f2a80' ? new ImageType(ImageFormat::CIN, MimeType::IMAGE_CINEON) : null;
return $bytes === '802a5fd7' || $bytes === 'd75f2a80' ? new ImageType(
ImageFormat::CIN,
MimeType::IMAGE_CINEON
) : null;
}
}
5 changes: 4 additions & 1 deletion src/Detector/HdrDetector.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ public function detect(SplFileObject $file): ?ImageType
{
$bytes = (string)$file->fread(10);

return $bytes === '#?RADIANCE' || $bytes === '#?RGBE' ? new ImageType(ImageFormat::HDR, MimeType::IMAGE_VND_RADIANCE) : null;
return $bytes === '#?RADIANCE' || $bytes === '#?RGBE' ? new ImageType(
ImageFormat::HDR,
MimeType::IMAGE_VND_RADIANCE
) : null;
}
}
5 changes: 4 additions & 1 deletion src/Detector/HeicDetector.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ public function detect(SplFileObject $file): ?ImageType
'msf1' => ImageFormat::HEIC_SEQUENCE,
];

return $bytes === 'ftyp' && isset($ccCodes[$ccCode]) ? new ImageType($ccCodes[$ccCode], MimeType::IMAGE_HEIC) : null;
return $bytes === 'ftyp' && isset($ccCodes[$ccCode]) ? new ImageType(
$ccCodes[$ccCode],
MimeType::IMAGE_HEIC
) : null;
}
}
6 changes: 4 additions & 2 deletions src/Detector/JpegHdrDetector.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ public function detect(SplFileObject $file): ?ImageType
{
$bytes = (string)$file->fread(50);

return (strpos($bytes, 'HDR_RI') !== false && strpos($bytes, 'ver=11') !== false) ?
new ImageType(ImageFormat::JPEG_HDR, MimeType::IMAGE_JPEG) : null;
return (strpos($bytes, 'HDR_RI') !== false && strpos($bytes, 'ver=11') !== false) ? new ImageType(
ImageFormat::JPEG_HDR,
MimeType::IMAGE_JPEG
) : null;
}
}
4 changes: 0 additions & 4 deletions src/ImageTypeDetector.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ public function addDetector(DetectorInterface $detector): void
* Add image detector provider.
*
* @param ProviderInterface $provider The provider
*
* @return void
*/
public function addProvider(ProviderInterface $provider): void
{
Expand Down Expand Up @@ -64,8 +62,6 @@ public function getImageTypeFromFile(SplFileObject $file): ImageType
* Reads and returns the type of the image.
*
* @param SplFileObject $file The image file
*
* @return ImageType|null
*/
private function detectFile(SplFileObject $file): ?ImageType
{
Expand Down
6 changes: 0 additions & 6 deletions tests/ImageTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ class ImageTypeTest extends TestCase
{
/**
* Test.
*
* @return void
*/
public function testCreateInstance(): void
{
Expand All @@ -28,8 +26,6 @@ public function testCreateInstance(): void

/**
* Test.
*
* @return void
*/
public function testCreateInstanceWithError(): void
{
Expand All @@ -39,8 +35,6 @@ public function testCreateInstanceWithError(): void

/**
* Test.
*
* @return void
*/
public function testCreateInstanceWithError2(): void
{
Expand Down
File renamed without changes.

0 comments on commit ccb8048

Please sign in to comment.