1
0
mirror of https://github.com/Intervention/image.git synced 2025-09-01 18:02:45 +02:00

Rename method & add docblocks

This commit is contained in:
Oliver Vogel
2023-12-03 19:44:32 +01:00
parent 9e369e1d57
commit 0e5328a575
3 changed files with 21 additions and 3 deletions

View File

@@ -20,6 +20,13 @@ abstract class AbstractDecoder implements DecoderInterface
// //
} }
/**
* Try to decode given input to image or color object
*
* @param mixed $input
* @return ImageInterface|ColorInterface
* @throws DecoderException
*/
final public function handle($input): ImageInterface|ColorInterface final public function handle($input): ImageInterface|ColorInterface
{ {
try { try {
@@ -35,6 +42,11 @@ abstract class AbstractDecoder implements DecoderInterface
return $decoded; return $decoded;
} }
/**
* Determine if current decoder has a successor
*
* @return bool
*/
protected function hasSuccessor(): bool protected function hasSuccessor(): bool
{ {
return $this->successor !== null; return $this->successor !== null;
@@ -55,7 +67,13 @@ abstract class AbstractDecoder implements DecoderInterface
return $type; return $type;
} }
protected function decodeExifData(string $image_data): CollectionInterface /**
* Extract and return EXIF data from given image data string
*
* @param string $image_data
* @return CollectionInterface
*/
protected function extractExifData(string $image_data): CollectionInterface
{ {
if (!function_exists('exif_read_data')) { if (!function_exists('exif_read_data')) {
return new Collection(); return new Collection();

View File

@@ -30,7 +30,7 @@ class BinaryImageDecoder extends AbstractDecoder implements DecoderInterface
$image = new Image( $image = new Image(
new Driver(), new Driver(),
$this->coreFromString($input), $this->coreFromString($input),
$this->decodeExifData($input) $this->extractExifData($input)
); );
// fix image orientation // fix image orientation

View File

@@ -51,7 +51,7 @@ class BinaryImageDecoder extends AbstractDecoder implements DecoderInterface
$image = new Image( $image = new Image(
new Driver(), new Driver(),
new Core($imagick), new Core($imagick),
$this->decodeExifData($input) $this->extractExifData($input)
); );
return $image; return $image;