diff --git a/lib/PHPExif/Adapter/AbstractAdapter.php b/lib/PHPExif/Adapter/AbstractAdapter.php index 6101b8d..2d54e52 100644 --- a/lib/PHPExif/Adapter/AbstractAdapter.php +++ b/lib/PHPExif/Adapter/AbstractAdapter.php @@ -43,7 +43,7 @@ public function __construct(array $options = array()) * @param \PHPExif\Contracts\MapperInterface $mapper * @return \PHPExif\Contracts\AdapterInterface */ - public function setMapper(MapperInterface $mapper) : AdapterInterface + public function setMapper(MapperInterface $mapper): AdapterInterface { $this->mapper = $mapper; @@ -55,12 +55,12 @@ public function setMapper(MapperInterface $mapper) : AdapterInterface * * @return \PHPExif\Contracts\MapperInterface */ - public function getMapper() : MapperInterface + public function getMapper(): MapperInterface { if (null === $this->mapper) { // lazy load one /** @var MapperInterface */ - $mapper = new $this->mapperClass; + $mapper = new $this->mapperClass(); $this->setMapper($mapper); } @@ -74,7 +74,7 @@ public function getMapper() : MapperInterface * @param \PHPExif\Contracts\HydratorInterface $hydrator * @return \PHPExif\Contracts\AdapterInterface */ - public function setHydrator(HydratorInterface $hydrator) : AdapterInterface + public function setHydrator(HydratorInterface $hydrator): AdapterInterface { $this->hydrator = $hydrator; @@ -86,12 +86,12 @@ public function setHydrator(HydratorInterface $hydrator) : AdapterInterface * * @return \PHPExif\Contracts\HydratorInterface */ - public function getHydrator() : HydratorInterface + public function getHydrator(): HydratorInterface { if (null === $this->hydrator) { // lazy load one /** @var HydratorInterface */ - $hydrator = new $this->hydratorClass; + $hydrator = new $this->hydratorClass(); $this->setHydrator($hydrator); } @@ -105,7 +105,7 @@ public function getHydrator() : HydratorInterface * @param array $options * @return \PHPExif\Contracts\AdapterInterface */ - public function setOptions(array $options) : AdapterInterface + public function setOptions(array $options): AdapterInterface { $hydrator = $this->getHydrator(); $hydrator->hydrate($this, $options); @@ -122,7 +122,7 @@ public function setOptions(array $options) : AdapterInterface */ // @codeCoverageIgnoreStart // this is fine because we use it directly in our tests for Exiftool and Native - public function convertToUTF8(array|string $data) : array|string + public function convertToUTF8(array|string $data): array|string { if (is_array($data)) { /** @var array|string|null $v */ diff --git a/lib/PHPExif/Adapter/Exiftool.php b/lib/PHPExif/Adapter/Exiftool.php index 2b25a77..cd977fd 100644 --- a/lib/PHPExif/Adapter/Exiftool.php +++ b/lib/PHPExif/Adapter/Exiftool.php @@ -5,9 +5,11 @@ use PHPExif\Exif; use InvalidArgumentException; use PHPExif\Mapper\Exiftool as MapperExiftool; -use RuntimeException; +use PHPExif\Reader\PhpExifReaderException; use Safe\Exceptions\ExecException; +use Safe\Exceptions\JsonException; + use function Safe\exec; use function Safe\json_decode; use function Safe\stream_get_contents; @@ -23,7 +25,7 @@ */ class Exiftool extends AbstractAdapter { - const TOOL_NAME = 'exiftool'; + public const TOOL_NAME = 'exiftool'; /** * Path to the exiftool binary @@ -40,7 +42,7 @@ class Exiftool extends AbstractAdapter * @return \PHPExif\Adapter\Exiftool Current instance * @throws \InvalidArgumentException When path is invalid */ - public function setToolPath(string $path) : Exiftool + public function setToolPath(string $path): Exiftool { if (!file_exists($path)) { throw new InvalidArgumentException( @@ -59,7 +61,7 @@ public function setToolPath(string $path) : Exiftool /** * @param boolean $numeric */ - public function setNumeric(bool $numeric) : void + public function setNumeric(bool $numeric): void { $this->numeric = $numeric; } @@ -68,7 +70,7 @@ public function setNumeric(bool $numeric) : void * @see http://www.sno.phy.queensu.ca/~phil/exiftool/faq.html#Q10 * @param array $encodings encoding parameters in an array eg. ["exif" => "UTF-8"] */ - public function setEncoding(array $encodings) : void + public function setEncoding(array $encodings): void { $possible_keys = array("exif", "iptc", "id3", "photoshop", "quicktime",); $possible_values = array("UTF8", "cp65001", "UTF-8", "Thai", "cp874", "Latin", "cp1252", @@ -90,7 +92,7 @@ public function setEncoding(array $encodings) : void * * @return string */ - public function getToolPath() : string + public function getToolPath(): string { if ($this->toolPath === '') { try { @@ -109,10 +111,10 @@ public function getToolPath() : string * Reads & parses the EXIF data from given file * * @param string $file - * @return \PHPExif\Exif Instance of Exif object with data - * @throws \RuntimeException If the EXIF data could not be read + * @return Exif Instance of Exif object with data + * @throws PhpExifReaderException If the EXIF data could not be read */ - public function getExifFromFile(string $file) : Exif + public function getExifFromFile(string $file): Exif { $encoding = ''; if (count($this->encoding) > 0) { @@ -136,14 +138,20 @@ public function getExifFromFile(string $file) : Exif ); /** - * @var string + * @var string $result */ $result = $this->convertToUTF8($result); - $data = json_decode($result, true); + try { + $data = json_decode($result, true); + } catch (JsonException $e) { + // @codeCoverageIgnoreStart + $data = false; + // @codeCoverageIgnoreStart + } if (!is_array($data)) { // @codeCoverageIgnoreStart - throw new RuntimeException( + throw new PhpExifReaderException( 'Could not decode exiftool output' ); // @codeCoverageIgnoreEnd @@ -171,9 +179,9 @@ public function getExifFromFile(string $file) : Exif * * @param string $command * @return string|false - * @throws RuntimeException If the command can't be executed + * @throws PhpExifReaderException If the command can't be executed */ - protected function getCliOutput(string $command) : string|false + protected function getCliOutput(string $command): string|false { $descriptorspec = array( 0 => array('pipe', 'r'), @@ -184,7 +192,7 @@ protected function getCliOutput(string $command) : string|false $process = proc_open($command, $descriptorspec, $pipes); if (!is_resource($process)) { - throw new RuntimeException( + throw new PhpExifReaderException( 'Could not open a resource to the exiftool binary' ); } diff --git a/lib/PHPExif/Adapter/FFprobe.php b/lib/PHPExif/Adapter/FFprobe.php index ccd5117..f68394b 100644 --- a/lib/PHPExif/Adapter/FFprobe.php +++ b/lib/PHPExif/Adapter/FFprobe.php @@ -15,7 +15,7 @@ use InvalidArgumentException; use FFMpeg; use PHPExif\Mapper\FFprobe as MapperFFprobe; -use RuntimeException; +use PHPExif\Reader\PhpExifReaderException; use Safe\Exceptions\ExecException; use function Safe\exec; @@ -113,7 +113,7 @@ public function getExifFromFile(string $file): Exif // file is not a video -> wrong adapter if (strpos($mimeType, 'video') !== 0) { - throw new RuntimeException('Could not read the video'); + throw new PhpExifReaderException('Could not read the video'); } $ffprobe = FFMpeg\FFProbe::create(array( diff --git a/lib/PHPExif/Adapter/ImageMagick.php b/lib/PHPExif/Adapter/ImageMagick.php index a1563ff..2528d28 100644 --- a/lib/PHPExif/Adapter/ImageMagick.php +++ b/lib/PHPExif/Adapter/ImageMagick.php @@ -21,7 +21,7 @@ */ class ImageMagick extends AbstractAdapter { - const TOOL_NAME = 'imagick'; + public const TOOL_NAME = 'imagick'; protected string $mapperClass = MapperImageMagick::class; @@ -49,7 +49,7 @@ class ImageMagick extends AbstractAdapter * @param string $file * @return \PHPExif\Exif Instance of Exif object with data */ - public function getExifFromFile(string $file) : Exif + public function getExifFromFile(string $file): Exif { /* Create the object */ $im = new Imagick($file); @@ -98,7 +98,7 @@ public function getExifFromFile(string $file) : Exif * @param string $profile Raw IPTC data * @return array */ - public function getIptcData(string $profile) : array + public function getIptcData(string $profile): array { $arrData = []; try { diff --git a/lib/PHPExif/Adapter/Native.php b/lib/PHPExif/Adapter/Native.php index 590dd7f..86c9d11 100644 --- a/lib/PHPExif/Adapter/Native.php +++ b/lib/PHPExif/Adapter/Native.php @@ -21,20 +21,20 @@ */ class Native extends AbstractAdapter { - const INCLUDE_THUMBNAIL = true; - const NO_THUMBNAIL = false; + public const INCLUDE_THUMBNAIL = true; + public const NO_THUMBNAIL = false; - const SECTIONS_AS_ARRAYS = true; - const SECTIONS_FLAT = false; + public const SECTIONS_AS_ARRAYS = true; + public const SECTIONS_FLAT = false; - const SECTION_FILE = 'FILE'; - const SECTION_COMPUTED = 'COMPUTED'; - const SECTION_IFD0 = 'IFD0'; - const SECTION_THUMBNAIL = 'THUMBNAIL'; - const SECTION_COMMENT = 'COMMENT'; - const SECTION_EXIF = 'EXIF'; - const SECTION_ALL = 'ANY_TAG'; - const SECTION_IPTC = 'IPTC'; + public const SECTION_FILE = 'FILE'; + public const SECTION_COMPUTED = 'COMPUTED'; + public const SECTION_IFD0 = 'IFD0'; + public const SECTION_THUMBNAIL = 'THUMBNAIL'; + public const SECTION_COMMENT = 'COMMENT'; + public const SECTION_EXIF = 'EXIF'; + public const SECTION_ALL = 'ANY_TAG'; + public const SECTION_IPTC = 'IPTC'; /** * List of EXIF sections @@ -79,7 +79,7 @@ class Native extends AbstractAdapter * * @return array */ - public function getRequiredSections() : array + public function getRequiredSections(): array { return $this->requiredSections; } @@ -90,7 +90,7 @@ public function getRequiredSections() : array * @param array $sections List of EXIF sections * @return \PHPExif\Adapter\Native Current instance for chaining */ - public function setRequiredSections(array $sections) : Native + public function setRequiredSections(array $sections): Native { $this->requiredSections = $sections; @@ -103,7 +103,7 @@ public function setRequiredSections(array $sections) : Native * @param string $section * @return \PHPExif\Adapter\Native Current instance for chaining */ - public function addRequiredSection(string $section) : Native + public function addRequiredSection(string $section): Native { if (!in_array($section, $this->requiredSections, true)) { array_push($this->requiredSections, $section); @@ -118,7 +118,7 @@ public function addRequiredSection(string $section) : Native * @param boolean $value * @return \PHPExif\Adapter\Native Current instance for chaining */ - public function setIncludeThumbnail(bool $value) : Native + public function setIncludeThumbnail(bool $value): Native { $this->includeThumbnail = $value; @@ -130,7 +130,7 @@ public function setIncludeThumbnail(bool $value) : Native * * @return boolean */ - public function getIncludeThumbnail() : bool + public function getIncludeThumbnail(): bool { return $this->includeThumbnail; } @@ -141,7 +141,7 @@ public function getIncludeThumbnail() : bool * @param boolean $value * @return \PHPExif\Adapter\Native Current instance for chaining */ - public function setSectionsAsArrays(bool $value) : Native + public function setSectionsAsArrays(bool $value): Native { $this->sectionsAsArrays = $value; @@ -153,7 +153,7 @@ public function setSectionsAsArrays(bool $value) : Native * * @return boolean */ - public function getSectionsAsArrays() : bool + public function getSectionsAsArrays(): bool { return $this->sectionsAsArrays; } @@ -164,7 +164,7 @@ public function getSectionsAsArrays() : bool * @param string $file * @return \PHPExif\Exif Instance of Exif object with data */ - public function getExifFromFile(string $file) : Exif + public function getExifFromFile(string $file): Exif { $mimeType = mime_content_type($file); @@ -245,7 +245,7 @@ public function getExifFromFile(string $file) : Exif * @param string $file The file to read the IPTC data from * @return array */ - public function getIptcData(string $file) : array + public function getIptcData(string $file): array { getimagesize($file, $info); $arrData = array(); diff --git a/lib/PHPExif/Adapter/NoAdapterException.php b/lib/PHPExif/Adapter/NoAdapterException.php deleted file mode 100644 index f8ad868..0000000 --- a/lib/PHPExif/Adapter/NoAdapterException.php +++ /dev/null @@ -1,21 +0,0 @@ -rawData = $data; @@ -97,7 +97,7 @@ public function setRawData(array $data) : Exif * * @return array */ - public function getRawData() : array + public function getRawData(): array { return $this->rawData; } @@ -108,7 +108,7 @@ public function getRawData() : array * @param array $data The data to set * @return Exif Current instance for chaining */ - public function setData(array $data) : Exif + public function setData(array $data): Exif { $this->data = $data; @@ -120,7 +120,7 @@ public function setData(array $data) : Exif * * @return array */ - public function getData() : array + public function getData(): array { return $this->data; } @@ -130,7 +130,7 @@ public function getData() : array * * @return string|false */ - public function getAperture() : string|false + public function getAperture(): string|false { if (!isset($this->data[self::APERTURE])) { return false; @@ -145,7 +145,7 @@ public function getAperture() : string|false * @param string $value * @return Exif */ - public function setAperture(string $value) : Exif + public function setAperture(string $value): Exif { $this->data[self::APERTURE] = $value; @@ -157,7 +157,7 @@ public function setAperture(string $value) : Exif * * @return string|false */ - public function getAuthor() : string|false + public function getAuthor(): string|false { if (!isset($this->data[self::AUTHOR])) { return false; @@ -172,7 +172,7 @@ public function getAuthor() : string|false * @param string $value * @return Exif */ - public function setAuthor(string $value) : Exif + public function setAuthor(string $value): Exif { $this->data[self::AUTHOR] = $value; @@ -184,7 +184,7 @@ public function setAuthor(string $value) : Exif * * @return string|false */ - public function getHeadline() : string|false + public function getHeadline(): string|false { if (!isset($this->data[self::HEADLINE])) { return false; @@ -199,7 +199,7 @@ public function getHeadline() : string|false * @param string $value * @return Exif */ - public function setHeadline(string $value) : Exif + public function setHeadline(string $value): Exif { $this->data[self::HEADLINE] = $value; @@ -211,7 +211,7 @@ public function setHeadline(string $value) : Exif * * @return string|false */ - public function getCredit() : string|false + public function getCredit(): string|false { if (!isset($this->data[self::CREDIT])) { return false; @@ -226,7 +226,7 @@ public function getCredit() : string|false * @param string $value * @return Exif */ - public function setCredit(string $value) : Exif + public function setCredit(string $value): Exif { $this->data[self::CREDIT] = $value; @@ -238,7 +238,7 @@ public function setCredit(string $value) : Exif * * @return string|false */ - public function getSource() : string|false + public function getSource(): string|false { if (!isset($this->data[self::SOURCE])) { return false; @@ -253,7 +253,7 @@ public function getSource() : string|false * @param string $value * @return Exif */ - public function setSource(string $value) : Exif + public function setSource(string $value): Exif { $this->data[self::SOURCE] = $value; @@ -265,7 +265,7 @@ public function setSource(string $value) : Exif * * @return string|false */ - public function getJobtitle() : string|false + public function getJobtitle(): string|false { if (!isset($this->data[self::JOB_TITLE])) { return false; @@ -280,7 +280,7 @@ public function getJobtitle() : string|false * @param string $value * @return Exif */ - public function setJobtitle(string $value) : Exif + public function setJobtitle(string $value): Exif { $this->data[self::JOB_TITLE] = $value; @@ -292,7 +292,7 @@ public function setJobtitle(string $value) : Exif * * @return string|false */ - public function getIso() : string|false + public function getIso(): string|false { if (!isset($this->data[self::ISO])) { return false; @@ -307,7 +307,7 @@ public function getIso() : string|false * @param string $value * @return Exif */ - public function setIso(string $value) : Exif + public function setIso(string $value): Exif { $this->data[self::ISO] = $value; @@ -319,7 +319,7 @@ public function setIso(string $value) : Exif * * @return string|false */ - public function getExposure() : string|false + public function getExposure(): string|false { if (!isset($this->data[self::EXPOSURE])) { return false; @@ -334,7 +334,7 @@ public function getExposure() : string|false * @param string $value * @return Exif */ - public function setExposure(string $value) : Exif + public function setExposure(string $value): Exif { $this->data[self::EXPOSURE] = $value; @@ -346,7 +346,7 @@ public function setExposure(string $value) : Exif * * @return float|false */ - public function getExposureMilliseconds() : float|false + public function getExposureMilliseconds(): float|false { if (!isset($this->data[self::EXPOSURE])) { return false; @@ -366,7 +366,7 @@ public function getExposureMilliseconds() : float|false * * @return string|false */ - public function getFocusDistance() : string|false + public function getFocusDistance(): string|false { if (!isset($this->data[self::FOCAL_DISTANCE])) { return false; @@ -381,7 +381,7 @@ public function getFocusDistance() : string|false * @param string $value * @return Exif */ - public function setFocusDistance(string $value) : Exif + public function setFocusDistance(string $value): Exif { $this->data[self::FOCAL_DISTANCE] = $value; @@ -393,7 +393,7 @@ public function setFocusDistance(string $value) : Exif * * @return string|false */ - public function getWidth() : string|false + public function getWidth(): string|false { if (!isset($this->data[self::WIDTH])) { return false; @@ -408,7 +408,7 @@ public function getWidth() : string|false * @param string $value * @return Exif */ - public function setWidth(string $value) : Exif + public function setWidth(string $value): Exif { $this->data[self::WIDTH] = $value; @@ -420,7 +420,7 @@ public function setWidth(string $value) : Exif * * @return string|false */ - public function getHeight() : string|false + public function getHeight(): string|false { if (!isset($this->data[self::HEIGHT])) { return false; @@ -435,7 +435,7 @@ public function getHeight() : string|false * @param string $value * @return Exif */ - public function setHeight(string $value) : Exif + public function setHeight(string $value): Exif { $this->data[self::HEIGHT] = $value; @@ -447,7 +447,7 @@ public function setHeight(string $value) : Exif * * @return string|false */ - public function getTitle() : string|false + public function getTitle(): string|false { if (!isset($this->data[self::TITLE])) { return false; @@ -462,7 +462,7 @@ public function getTitle() : string|false * @param string $value * @return Exif */ - public function setTitle(string $value) : Exif + public function setTitle(string $value): Exif { $this->data[self::TITLE] = $value; @@ -474,7 +474,7 @@ public function setTitle(string $value) : Exif * * @return string|false */ - public function getCaption() : string|false + public function getCaption(): string|false { if (!isset($this->data[self::CAPTION])) { return false; @@ -489,7 +489,7 @@ public function getCaption() : string|false * @param string $value * @return Exif */ - public function setCaption(string $value) : Exif + public function setCaption(string $value): Exif { $this->data[self::CAPTION] = $value; @@ -501,7 +501,7 @@ public function setCaption(string $value) : Exif * * @return string|false */ - public function getCopyright() : string|false + public function getCopyright(): string|false { if (!isset($this->data[self::COPYRIGHT])) { return false; @@ -516,7 +516,7 @@ public function getCopyright() : string|false * @param string $value * @return Exif */ - public function setCopyright(string $value) : Exif + public function setCopyright(string $value): Exif { $this->data[self::COPYRIGHT] = $value; @@ -528,7 +528,7 @@ public function setCopyright(string $value) : Exif * * @return array|false */ - public function getKeywords() : array|false + public function getKeywords(): array|false { if (!isset($this->data[self::KEYWORDS])) { return false; @@ -543,7 +543,7 @@ public function getKeywords() : array|false * @param string|array $value * @return Exif */ - public function setKeywords(string|array $value) : Exif + public function setKeywords(string|array $value): Exif { $this->data[self::KEYWORDS] = $value; @@ -555,7 +555,7 @@ public function setKeywords(string|array $value) : Exif * * @return string|false */ - public function getCamera() : string|false + public function getCamera(): string|false { if (!isset($this->data[self::CAMERA])) { return false; @@ -570,7 +570,7 @@ public function getCamera() : string|false * @param string $value * @return Exif */ - public function setCamera(string $value) : Exif + public function setCamera(string $value): Exif { $this->data[self::CAMERA] = $value; @@ -582,7 +582,7 @@ public function setCamera(string $value) : Exif * * @return string|false */ - public function getHorizontalResolution() : string|false + public function getHorizontalResolution(): string|false { if (!isset($this->data[self::HORIZONTAL_RESOLUTION])) { return false; @@ -597,7 +597,7 @@ public function getHorizontalResolution() : string|false * @param string $value * @return Exif */ - public function setHorizontalResolution(string $value) : Exif + public function setHorizontalResolution(string $value): Exif { $this->data[self::HORIZONTAL_RESOLUTION] = $value; @@ -609,7 +609,7 @@ public function setHorizontalResolution(string $value) : Exif * * @return string|false */ - public function getVerticalResolution() : string|false + public function getVerticalResolution(): string|false { if (!isset($this->data[self::VERTICAL_RESOLUTION])) { return false; @@ -624,7 +624,7 @@ public function getVerticalResolution() : string|false * @param string $value * @return Exif */ - public function setVerticalResolution(string $value) : Exif + public function setVerticalResolution(string $value): Exif { $this->data[self::VERTICAL_RESOLUTION] = $value; @@ -636,7 +636,7 @@ public function setVerticalResolution(string $value) : Exif * * @return string|false */ - public function getSoftware() : string|false + public function getSoftware(): string|false { if (!isset($this->data[self::SOFTWARE])) { return false; @@ -651,7 +651,7 @@ public function getSoftware() : string|false * @param string $value * @return Exif */ - public function setSoftware(string $value) : Exif + public function setSoftware(string $value): Exif { $this->data[self::SOFTWARE] = trim($value); @@ -663,7 +663,7 @@ public function setSoftware(string $value) : Exif * * @return string|false */ - public function getFocalLength() : string|false + public function getFocalLength(): string|false { if (!isset($this->data[self::FOCAL_LENGTH])) { return false; @@ -678,7 +678,7 @@ public function getFocalLength() : string|false * @param string $value * @return Exif */ - public function setFocalLength(string $value) : Exif + public function setFocalLength(string $value): Exif { $this->data[self::FOCAL_LENGTH] = $value; @@ -690,7 +690,7 @@ public function setFocalLength(string $value) : Exif * * @return DateTime|false */ - public function getCreationDate() : DateTime|false + public function getCreationDate(): DateTime|false { if (!isset($this->data[self::CREATION_DATE])) { return false; @@ -705,7 +705,7 @@ public function getCreationDate() : DateTime|false * @param \DateTime $value * @return Exif */ - public function setCreationDate(DateTime $value) : Exif + public function setCreationDate(DateTime $value): Exif { $this->data[self::CREATION_DATE] = $value; @@ -717,7 +717,7 @@ public function setCreationDate(DateTime $value) : Exif * * @return string|false */ - public function getColorSpace() : string|false + public function getColorSpace(): string|false { if (!isset($this->data[self::COLORSPACE])) { return false; @@ -732,7 +732,7 @@ public function getColorSpace() : string|false * @param string $value * @return Exif */ - public function setColorSpace(string $value) : Exif + public function setColorSpace(string $value): Exif { $this->data[self::COLORSPACE] = $value; @@ -744,7 +744,7 @@ public function setColorSpace(string $value) : Exif * * @return string|false */ - public function getMimeType() : string|false + public function getMimeType(): string|false { if (!isset($this->data[self::MIMETYPE])) { return false; @@ -759,7 +759,7 @@ public function getMimeType() : string|false * @param string $value * @return Exif */ - public function setMimeType(string $value) : Exif + public function setMimeType(string $value): Exif { $this->data[self::MIMETYPE] = $value; @@ -771,7 +771,7 @@ public function setMimeType(string $value) : Exif * * @return int|false */ - public function getFileSize() : int|false + public function getFileSize(): int|false { if (!isset($this->data[self::FILESIZE])) { return false; @@ -786,7 +786,7 @@ public function getFileSize() : int|false * @param int $value * @return Exif */ - public function setFileSize(int $value) : Exif + public function setFileSize(int $value): Exif { $this->data[self::FILESIZE] = $value; @@ -798,7 +798,7 @@ public function setFileSize(int $value) : Exif * * @return string|false */ - public function getFileName() : string|false + public function getFileName(): string|false { if (!isset($this->data[self::FILENAME])) { return false; @@ -813,7 +813,7 @@ public function getFileName() : string|false * @param string $value * @return Exif */ - public function setFileName(string $value) : Exif + public function setFileName(string $value): Exif { $this->data[self::FILENAME] = $value; @@ -825,7 +825,7 @@ public function setFileName(string $value) : Exif * * @return string|false */ - public function getOrientation() : string|false + public function getOrientation(): string|false { if (!isset($this->data[self::ORIENTATION])) { return false; @@ -840,7 +840,7 @@ public function getOrientation() : string|false * @param string $value * @return Exif */ - public function setOrientation(string $value) : Exif + public function setOrientation(string $value): Exif { $this->data[self::ORIENTATION] = $value; @@ -852,7 +852,7 @@ public function setOrientation(string $value) : Exif * * @return string|false */ - public function getGPS() : string|false + public function getGPS(): string|false { if (!isset($this->data[self::GPS])) { return false; @@ -867,7 +867,7 @@ public function getGPS() : string|false * @param string $value * @return Exif */ - public function setGPS(string $value) : Exif + public function setGPS(string $value): Exif { $this->data[self::GPS] = $value; @@ -880,7 +880,7 @@ public function setGPS(string $value) : Exif * @param string $value * @return Exif */ - public function setDescription(string $value) : Exif + public function setDescription(string $value): Exif { $this->data[self::DESCRIPTION] = $value; @@ -892,7 +892,7 @@ public function setDescription(string $value) : Exif * * @return string|false */ - public function getDescription() : string|false + public function getDescription(): string|false { if (!isset($this->data[self::DESCRIPTION])) { return false; @@ -908,7 +908,7 @@ public function getDescription() : string|false * @param string $value * @return Exif */ - public function setMake(string $value) : Exif + public function setMake(string $value): Exif { $this->data[self::MAKE] = $value; @@ -920,7 +920,7 @@ public function setMake(string $value) : Exif * * @return string|false */ - public function getMake() : string|false + public function getMake(): string|false { if (!isset($this->data[self::MAKE])) { return false; @@ -935,7 +935,7 @@ public function getMake() : string|false * @param float $value * @return Exif */ - public function setAltitude(float $value) : Exif + public function setAltitude(float $value): Exif { $this->data[self::ALTITUDE] = $value; @@ -947,7 +947,7 @@ public function setAltitude(float $value) : Exif * * @return float|false */ - public function getAltitude() : float|false + public function getAltitude(): float|false { if (!isset($this->data[self::ALTITUDE])) { return false; @@ -962,7 +962,7 @@ public function getAltitude() : float|false * @param float $value * @return Exif */ - public function setLongitude(float $value) : Exif + public function setLongitude(float $value): Exif { $this->data[self::LONGITUDE] = $value; @@ -974,7 +974,7 @@ public function setLongitude(float $value) : Exif * * @return float|false */ - public function getLongitude() : float|false + public function getLongitude(): float|false { if (!isset($this->data[self::LONGITUDE])) { return false; @@ -989,7 +989,7 @@ public function getLongitude() : float|false * @param float $value * @return Exif */ - public function setLatitude(float $value) : Exif + public function setLatitude(float $value): Exif { $this->data[self::LATITUDE] = $value; @@ -1001,7 +1001,7 @@ public function setLatitude(float $value) : Exif * * @return float|false */ - public function getLatitude() : float|false + public function getLatitude(): float|false { if (!isset($this->data[self::LATITUDE])) { return false; @@ -1016,7 +1016,7 @@ public function getLatitude() : float|false * @param float $value * @return Exif */ - public function setImgDirection(float $value) : Exif + public function setImgDirection(float $value): Exif { $this->data[self::IMGDIRECTION] = $value; @@ -1028,7 +1028,7 @@ public function setImgDirection(float $value) : Exif * * @return float|false */ - public function getImgDirection() : float|false + public function getImgDirection(): float|false { if (!isset($this->data[self::IMGDIRECTION])) { return false; @@ -1044,7 +1044,7 @@ public function getImgDirection() : float|false * @param string $value * @return Exif */ - public function setLens(string $value) : Exif + public function setLens(string $value): Exif { $this->data[self::LENS] = $value; @@ -1056,7 +1056,7 @@ public function setLens(string $value) : Exif * * @return string|false */ - public function getLens() : string|false + public function getLens(): string|false { if (!isset($this->data[self::LENS])) { return false; @@ -1071,7 +1071,7 @@ public function getLens() : string|false * @param string $value * @return Exif */ - public function setContentIdentifier(string $value) : Exif + public function setContentIdentifier(string $value): Exif { $this->data[self::CONTENTIDENTIFIER] = $value; @@ -1083,7 +1083,7 @@ public function setContentIdentifier(string $value) : Exif * * @return string|false */ - public function getContentIdentifier() : string|false + public function getContentIdentifier(): string|false { if (!isset($this->data[self::CONTENTIDENTIFIER])) { return false; @@ -1099,7 +1099,7 @@ public function getContentIdentifier() : string|false * @param string $value * @return Exif */ - public function setFramerate(string $value) : Exif + public function setFramerate(string $value): Exif { $this->data[self::FRAMERATE] = $value; @@ -1111,7 +1111,7 @@ public function setFramerate(string $value) : Exif * * @return string|false */ - public function getFramerate() : string|false + public function getFramerate(): string|false { if (!isset($this->data[self::FRAMERATE])) { return false; @@ -1127,7 +1127,7 @@ public function getFramerate() : string|false * @param string $value * @return Exif */ - public function setDuration(string $value) : Exif + public function setDuration(string $value): Exif { $this->data[self::DURATION] = $value; @@ -1139,7 +1139,7 @@ public function setDuration(string $value) : Exif * * @return string|false */ - public function getDuration() : string|false + public function getDuration(): string|false { if (!isset($this->data[self::DURATION])) { return false; @@ -1153,7 +1153,7 @@ public function getDuration() : string|false * @param string $value * @return Exif */ - public function setMicroVideoOffset(string $value) : Exif + public function setMicroVideoOffset(string $value): Exif { $this->data[self::MICROVIDEOOFFSET] = $value; @@ -1165,7 +1165,7 @@ public function setMicroVideoOffset(string $value) : Exif * * @return string|false */ - public function getMicroVideoOffset() : string|false + public function getMicroVideoOffset(): string|false { if (!isset($this->data[self::MICROVIDEOOFFSET])) { return false; @@ -1180,7 +1180,7 @@ public function getMicroVideoOffset() : string|false * @param string $value * @return Exif */ - public function setSublocation(string $value) : Exif + public function setSublocation(string $value): Exif { $this->data[self::SUBLOCATION] = $value; @@ -1192,7 +1192,7 @@ public function setSublocation(string $value) : Exif * * @return string|false */ - public function getSublocation() : string|false + public function getSublocation(): string|false { if (!isset($this->data[self::SUBLOCATION])) { return false; @@ -1207,7 +1207,7 @@ public function getSublocation() : string|false * @param string $value * @return Exif */ - public function setCity(string $value) : Exif + public function setCity(string $value): Exif { $this->data[self::CITY] = $value; @@ -1219,7 +1219,7 @@ public function setCity(string $value) : Exif * * @return string|false */ - public function getCity() : string|false + public function getCity(): string|false { if (!isset($this->data[self::CITY])) { return false; @@ -1234,7 +1234,7 @@ public function getCity() : string|false * @param string $value * @return Exif */ - public function setState(string $value) : Exif + public function setState(string $value): Exif { $this->data[self::STATE] = $value; @@ -1246,7 +1246,7 @@ public function setState(string $value) : Exif * * @return string|false */ - public function getState() : string|false + public function getState(): string|false { if (!isset($this->data[self::STATE])) { return false; @@ -1261,7 +1261,7 @@ public function getState() : string|false * @param string $value * @return Exif */ - public function setCountry(string $value) : Exif + public function setCountry(string $value): Exif { $this->data[self::COUNTRY] = $value; @@ -1273,7 +1273,7 @@ public function setCountry(string $value) : Exif * * @return string|false */ - public function getCountry() : string|false + public function getCountry(): string|false { if (!isset($this->data[self::COUNTRY])) { return false; diff --git a/lib/PHPExif/Hydrator/Mutator.php b/lib/PHPExif/Hydrator/Mutator.php index d35267d..ecbbf8f 100644 --- a/lib/PHPExif/Hydrator/Mutator.php +++ b/lib/PHPExif/Hydrator/Mutator.php @@ -22,7 +22,7 @@ class Mutator implements HydratorInterface * @param array $data * @return void */ - public function hydrate($object, array $data) : void + public function hydrate($object, array $data): void { foreach ($data as $property => $value) { if ($value !== null && $value !== '') { @@ -41,7 +41,7 @@ public function hydrate($object, array $data) : void * @param string $property The property to determine the mutator for * @return string The name of the mutator method */ - protected function determineMutator(string $property) : string + protected function determineMutator(string $property): string { $method = 'set' . ucfirst($property); return $method; diff --git a/lib/PHPExif/Mapper/AbstractMapper.php b/lib/PHPExif/Mapper/AbstractMapper.php index 2523143..b8d1c13 100644 --- a/lib/PHPExif/Mapper/AbstractMapper.php +++ b/lib/PHPExif/Mapper/AbstractMapper.php @@ -22,7 +22,7 @@ abstract class AbstractMapper implements MapperInterface * @param mixed $data * @return mixed */ - public function trim(mixed $data) : mixed + public function trim(mixed $data): mixed { if (is_array($data)) { /** @var mixed $v */ diff --git a/lib/PHPExif/Mapper/FFprobe.php b/lib/PHPExif/Mapper/FFprobe.php index 54e6460..44bac50 100644 --- a/lib/PHPExif/Mapper/FFprobe.php +++ b/lib/PHPExif/Mapper/FFprobe.php @@ -17,27 +17,27 @@ */ class FFprobe extends AbstractMapper { - const HEIGHT = 'height'; - const WIDTH = 'width'; - const FILESIZE = 'size'; - const FILENAME = 'filename'; - const FRAMERATE = 'avg_frame_rate'; - const DURATION = 'duration'; - const DATETIMEORIGINAL = 'creation_time'; - const GPSLATITUDE = 'location'; - const GPSLONGITUDE = 'location'; - const MIMETYPE = 'MimeType'; - - const QUICKTIME_GPSLATITUDE = 'com.apple.quicktime.location.ISO6709'; - const QUICKTIME_GPSLONGITUDE = 'com.apple.quicktime.location.ISO6709'; - const QUICKTIME_GPSALTITUDE = 'com.apple.quicktime.location.ISO6709'; - const QUICKTIME_DATE = 'com.apple.quicktime.creationdate'; - const QUICKTIME_DESCRIPTION = 'com.apple.quicktime.description'; - const QUICKTIME_TITLE = 'com.apple.quicktime.title'; - const QUICKTIME_KEYWORDS = 'com.apple.quicktime.keywords'; - const QUICKTIME_MAKE = 'com.apple.quicktime.make'; - const QUICKTIME_MODEL = 'com.apple.quicktime.model'; - const QUICKTIME_CONTENTIDENTIFIER = 'com.apple.quicktime.content.identifier'; + public const HEIGHT = 'height'; + public const WIDTH = 'width'; + public const FILESIZE = 'size'; + public const FILENAME = 'filename'; + public const FRAMERATE = 'avg_frame_rate'; + public const DURATION = 'duration'; + public const DATETIMEORIGINAL = 'creation_time'; + public const GPSLATITUDE = 'location'; + public const GPSLONGITUDE = 'location'; + public const MIMETYPE = 'MimeType'; + + public const QUICKTIME_GPSLATITUDE = 'com.apple.quicktime.location.ISO6709'; + public const QUICKTIME_GPSLONGITUDE = 'com.apple.quicktime.location.ISO6709'; + public const QUICKTIME_GPSALTITUDE = 'com.apple.quicktime.location.ISO6709'; + public const QUICKTIME_DATE = 'com.apple.quicktime.creationdate'; + public const QUICKTIME_DESCRIPTION = 'com.apple.quicktime.description'; + public const QUICKTIME_TITLE = 'com.apple.quicktime.title'; + public const QUICKTIME_KEYWORDS = 'com.apple.quicktime.keywords'; + public const QUICKTIME_MAKE = 'com.apple.quicktime.make'; + public const QUICKTIME_MODEL = 'com.apple.quicktime.model'; + public const QUICKTIME_CONTENTIDENTIFIER = 'com.apple.quicktime.content.identifier'; /** @@ -70,7 +70,7 @@ class FFprobe extends AbstractMapper self::QUICKTIME_CONTENTIDENTIFIER => Exif::CONTENTIDENTIFIER, ); - const SECTION_TAGS = 'tags'; + public const SECTION_TAGS = 'tags'; /** * A list of section names @@ -88,7 +88,7 @@ class FFprobe extends AbstractMapper * @param array $data * @return array */ - public function mapRawData(array $data) : array + public function mapRawData(array $data): array { $mappedData = array(); @@ -195,7 +195,7 @@ public function mapRawData(array $data) : array * @param string $field * @return bool */ - protected function isSection(string $field) : bool + protected function isSection(string $field): bool { return (in_array($field, $this->sections, true)); } @@ -208,7 +208,7 @@ protected function isSection(string $field) : bool * @param string &$field * @return bool */ - protected function isFieldKnown(string &$field) : bool + protected function isFieldKnown(string &$field): bool { $lcfField = lcfirst($field); if (array_key_exists($lcfField, $this->map)) { @@ -233,7 +233,7 @@ protected function isFieldKnown(string &$field) : bool * @param string $rational * @return float|false */ - protected function normalizeComponent(string $rational) : float|false + protected function normalizeComponent(string $rational): float|false { $parts = explode('/', $rational, 2); if (count($parts) === 1) { @@ -268,7 +268,7 @@ public function convertDMStoDecimal( string $minutes, string $seconds, string $fraction - ) : float { + ): float { if ($fraction !== '') { if ($seconds !== '') { $seconds = $seconds . $fraction; @@ -294,7 +294,7 @@ public function convertDMStoDecimal( * * @return array */ - public function readISO6709(string $val_ISO6709) : array + public function readISO6709(string $val_ISO6709): array { $return = [ 'latitude' => null, diff --git a/lib/PHPExif/Mapper/ImageMagick.php b/lib/PHPExif/Mapper/ImageMagick.php index 4d750d8..426f218 100644 --- a/lib/PHPExif/Mapper/ImageMagick.php +++ b/lib/PHPExif/Mapper/ImageMagick.php @@ -19,48 +19,48 @@ */ class ImageMagick extends AbstractMapper { - const APERTURE = 'exif:FNumber'; - const ARTIST = 'exif:Artist'; - const COLORSPACE = 'exif:ColorSpace'; - const COPYRIGHT = 'exif:Copyright'; - const CREATION_DATE = 'date:create'; - const DATETIMEORIGINAL = 'exif:DateTimeOriginal'; - const DESCRIPTION = 'exif:ImageDescription'; - const EXPOSURETIME = 'exif:ExposureTime'; - const FILESIZE = 'filesize'; - const FILENAME = 'filename'; - const FOCALLENGTH = 'exif:FocalLength'; - const GPSLATITUDE = 'exif:GPSLatitude'; - const GPSLONGITUDE = 'exif:GPSLongitude'; - const GPSALTITUDE = 'exif:GPSAltitude'; - const IMAGEHEIGHT = 'exif:PixelYDimension'; - const IMAGEHEIGHT_PNG = 'png:IHDR.width,height'; - const HEIGHT = 'height'; - const IMAGEWIDTH = 'exif:PixelXDimension'; - const IMAGEWIDTH_PNG = 'png:IHDR.width,height'; - const WIDTH = 'width'; - const IMGDIRECTION = 'exif:GPSImgDirection'; - const ISO = 'exif:PhotographicSensitivity'; - const LENS = 'exif:LensModel'; - const MAKE = 'exif:Make'; - const MIMETYPE = 'MimeType'; - const MODEL = 'exif:Model'; - const ORIENTATION = 'exif:Orientation'; - const SOFTWARE = 'exif:Software'; - const XRESOLUTION = 'exif:XResolution'; - const YRESOLUTION = 'exif:YResolution'; - const TITLE = 'iptc:title'; - const KEYWORDS = 'iptc:keywords'; - const COPYRIGHT_IPTC = 'iptc:copyright'; - const CAPTION = 'iptc:caption'; - const HEADLINE = 'iptc:headline'; - const CREDIT = 'iptc:credit'; - const SOURCE = 'iptc:source'; - const JOBTITLE = 'iptc:jobtitle'; - const CITY = 'iptc:city'; - const SUBLOCATION = 'iptc:sublocation'; - const STATE = 'iptc:state'; - const COUNTRY = 'iptc:country'; + public const APERTURE = 'exif:FNumber'; + public const ARTIST = 'exif:Artist'; + public const COLORSPACE = 'exif:ColorSpace'; + public const COPYRIGHT = 'exif:Copyright'; + public const CREATION_DATE = 'date:create'; + public const DATETIMEORIGINAL = 'exif:DateTimeOriginal'; + public const DESCRIPTION = 'exif:ImageDescription'; + public const EXPOSURETIME = 'exif:ExposureTime'; + public const FILESIZE = 'filesize'; + public const FILENAME = 'filename'; + public const FOCALLENGTH = 'exif:FocalLength'; + public const GPSLATITUDE = 'exif:GPSLatitude'; + public const GPSLONGITUDE = 'exif:GPSLongitude'; + public const GPSALTITUDE = 'exif:GPSAltitude'; + public const IMAGEHEIGHT = 'exif:PixelYDimension'; + public const IMAGEHEIGHT_PNG = 'png:IHDR.width,height'; + public const HEIGHT = 'height'; + public const IMAGEWIDTH = 'exif:PixelXDimension'; + public const IMAGEWIDTH_PNG = 'png:IHDR.width,height'; + public const WIDTH = 'width'; + public const IMGDIRECTION = 'exif:GPSImgDirection'; + public const ISO = 'exif:PhotographicSensitivity'; + public const LENS = 'exif:LensModel'; + public const MAKE = 'exif:Make'; + public const MIMETYPE = 'MimeType'; + public const MODEL = 'exif:Model'; + public const ORIENTATION = 'exif:Orientation'; + public const SOFTWARE = 'exif:Software'; + public const XRESOLUTION = 'exif:XResolution'; + public const YRESOLUTION = 'exif:YResolution'; + public const TITLE = 'iptc:title'; + public const KEYWORDS = 'iptc:keywords'; + public const COPYRIGHT_IPTC = 'iptc:copyright'; + public const CAPTION = 'iptc:caption'; + public const HEADLINE = 'iptc:headline'; + public const CREDIT = 'iptc:credit'; + public const SOURCE = 'iptc:source'; + public const JOBTITLE = 'iptc:jobtitle'; + public const CITY = 'iptc:city'; + public const SUBLOCATION = 'iptc:sublocation'; + public const STATE = 'iptc:state'; + public const COUNTRY = 'iptc:country'; /** @@ -123,7 +123,7 @@ class ImageMagick extends AbstractMapper * @param array $data * @return array */ - public function mapRawData(array $data) : array + public function mapRawData(array $data): array { $mappedData = array(); @@ -276,7 +276,7 @@ public function mapRawData(array $data) : array * @param string $coordinates * @return float|false */ - protected function extractGPSCoordinates(string $coordinates) : float|false + protected function extractGPSCoordinates(string $coordinates): float|false { if (is_numeric($coordinates) === true) { return ((float) $coordinates); @@ -301,7 +301,7 @@ protected function extractGPSCoordinates(string $coordinates) : float|false * @param string $rational * @return float|false */ - protected function normalizeComponent(string $rational) : float|false + protected function normalizeComponent(string $rational): float|false { $parts = explode('/', $rational, 2); if (count($parts) === 1) { diff --git a/lib/PHPExif/Mapper/Native.php b/lib/PHPExif/Mapper/Native.php index 8e4bf8f..84a7298 100644 --- a/lib/PHPExif/Mapper/Native.php +++ b/lib/PHPExif/Mapper/Native.php @@ -18,57 +18,57 @@ */ class Native extends AbstractMapper { - const APERTUREFNUMBER = 'ApertureFNumber'; - const ARTIST = 'Artist'; - const CAPTION = 'caption'; - const COLORSPACE = 'ColorSpace'; - const COPYRIGHT = 'copyright'; - const DATETIMEORIGINAL = 'DateTimeOriginal'; - const CREDIT = 'credit'; - const EXPOSURETIME = 'ExposureTime'; - const FILESIZE = 'FileSize'; - const FILENAME = 'FileName'; - const FOCALLENGTH = 'FocalLength'; - const FOCUSDISTANCE = 'FocusDistance'; - const HEADLINE = 'headline'; - const HEIGHT = 'Height'; - const ISOSPEEDRATINGS = 'ISOSpeedRatings'; - const JOBTITLE = 'jobtitle'; - const KEYWORDS = 'keywords'; - const MIMETYPE = 'MimeType'; - const MODEL = 'Model'; - const ORIENTATION = 'Orientation'; - const SOFTWARE = 'Software'; - const SOURCE = 'source'; - const TITLE = 'title'; - const WIDTH = 'Width'; - const XRESOLUTION = 'XResolution'; - const YRESOLUTION = 'YResolution'; - const GPSLATITUDE = 'GPSLatitude'; - const GPSLONGITUDE = 'GPSLongitude'; - const GPSALTITUDE = 'GPSAltitude'; - const IMGDIRECTION = 'GPSImgDirection'; - const MAKE = 'Make'; - const LENS = 'LensInfo'; - const LENS_LR = 'UndefinedTag:0xA434'; - const LENS_TYPE = 'LensType'; - const DESCRIPTION = 'ImageDescription'; - const SUBJECT = 'subject'; - const FRAMERATE = 'framerate'; - const DURATION = 'duration'; - const CITY = 'city'; - const SUBLOCATION = 'sublocation'; - const STATE = 'state'; - const COUNTRY = 'country'; + public const APERTUREFNUMBER = 'ApertureFNumber'; + public const ARTIST = 'Artist'; + public const CAPTION = 'caption'; + public const COLORSPACE = 'ColorSpace'; + public const COPYRIGHT = 'copyright'; + public const DATETIMEORIGINAL = 'DateTimeOriginal'; + public const CREDIT = 'credit'; + public const EXPOSURETIME = 'ExposureTime'; + public const FILESIZE = 'FileSize'; + public const FILENAME = 'FileName'; + public const FOCALLENGTH = 'FocalLength'; + public const FOCUSDISTANCE = 'FocusDistance'; + public const HEADLINE = 'headline'; + public const HEIGHT = 'Height'; + public const ISOSPEEDRATINGS = 'ISOSpeedRatings'; + public const JOBTITLE = 'jobtitle'; + public const KEYWORDS = 'keywords'; + public const MIMETYPE = 'MimeType'; + public const MODEL = 'Model'; + public const ORIENTATION = 'Orientation'; + public const SOFTWARE = 'Software'; + public const SOURCE = 'source'; + public const TITLE = 'title'; + public const WIDTH = 'Width'; + public const XRESOLUTION = 'XResolution'; + public const YRESOLUTION = 'YResolution'; + public const GPSLATITUDE = 'GPSLatitude'; + public const GPSLONGITUDE = 'GPSLongitude'; + public const GPSALTITUDE = 'GPSAltitude'; + public const IMGDIRECTION = 'GPSImgDirection'; + public const MAKE = 'Make'; + public const LENS = 'LensInfo'; + public const LENS_LR = 'UndefinedTag:0xA434'; + public const LENS_TYPE = 'LensType'; + public const DESCRIPTION = 'ImageDescription'; + public const SUBJECT = 'subject'; + public const FRAMERATE = 'framerate'; + public const DURATION = 'duration'; + public const CITY = 'city'; + public const SUBLOCATION = 'sublocation'; + public const STATE = 'state'; + public const COUNTRY = 'country'; - const SECTION_FILE = 'FILE'; - const SECTION_COMPUTED = 'COMPUTED'; - const SECTION_IFD0 = 'IFD0'; - const SECTION_THUMBNAIL = 'THUMBNAIL'; - const SECTION_COMMENT = 'COMMENT'; - const SECTION_EXIF = 'EXIF'; - const SECTION_ALL = 'ANY_TAG'; - const SECTION_IPTC = 'IPTC'; + public const SECTION_FILE = 'FILE'; + public const SECTION_COMPUTED = 'COMPUTED'; + public const SECTION_IFD0 = 'IFD0'; + public const SECTION_THUMBNAIL = 'THUMBNAIL'; + public const SECTION_COMMENT = 'COMMENT'; + public const SECTION_EXIF = 'EXIF'; + public const SECTION_ALL = 'ANY_TAG'; + public const SECTION_IPTC = 'IPTC'; /** * A list of section names @@ -145,7 +145,7 @@ class Native extends AbstractMapper * @param array $data * @return array */ - public function mapRawData(array $data) : array + public function mapRawData(array $data): array { $mappedData = array(); @@ -264,7 +264,7 @@ public function mapRawData(array $data) : array continue 2; } break; - // Merge sources of keywords + // Merge sources of keywords case self::KEYWORDS: case self::SUBJECT: $xval = is_array($value) ? $value : [$value]; @@ -307,7 +307,7 @@ public function mapRawData(array $data) : array * @param string $field * @return bool */ - protected function isSection(string $field) : bool + protected function isSection(string $field): bool { return (in_array($field, $this->sections, true)); } @@ -320,7 +320,7 @@ protected function isSection(string $field) : bool * @param string &$field * @return bool */ - protected function isFieldKnown(string &$field) : bool + protected function isFieldKnown(string &$field): bool { $lcfField = lcfirst($field); if (array_key_exists($lcfField, $this->map)) { @@ -346,7 +346,7 @@ protected function isFieldKnown(string &$field) : bool * @param string $ref * @return float|false */ - protected function extractGPSCoordinate(array $coordinate, string $ref) : float|false + protected function extractGPSCoordinate(array $coordinate, string $ref): float|false { $degrees = count($coordinate) > 0 ? $this->normalizeComponent($coordinate[0]) : 0; $minutes = count($coordinate) > 1 ? $this->normalizeComponent($coordinate[1]) : 0; @@ -364,7 +364,7 @@ protected function extractGPSCoordinate(array $coordinate, string $ref) : float| * @param string $rational * @return float|false */ - protected function normalizeComponent(string $rational) : float|false + protected function normalizeComponent(string $rational): float|false { $parts = explode('/', $rational, 2); if (count($parts) === 1) { diff --git a/lib/PHPExif/Reader/PhpExifReaderException.php b/lib/PHPExif/Reader/PhpExifReaderException.php new file mode 100644 index 0000000..b6dfcf3 --- /dev/null +++ b/lib/PHPExif/Reader/PhpExifReaderException.php @@ -0,0 +1,7 @@ +adapter = $adapter; - } - - /** - * Getter for the reader adapter - * - * @return \PHPExif\Contracts\AdapterInterface - * @throws NoAdapterException When no adapter is set - */ - public function getAdapter(): AdapterInterface - { - if ($this->adapter === null) { - throw new NoAdapterException('No adapter set in the reader'); - } - - return $this->adapter; } /** @@ -76,21 +54,10 @@ public static function factory(ReaderType $type): Reader * Reads & parses the EXIF data from given file * * @param string $file - * @return \PHPExif\Exif Instance of Exif object with data + * @return Exif Instance of Exif object with data */ public function read(string $file): Exif { - return $this->getAdapter()->getExifFromFile($file); - } - - /** - * alias to read method - * - * @param string $file - * @return \PHPExif\Exif Instance of Exif object with data - */ - public function getExifFromFile(string $file): Exif - { - return $this->read($file); + return $this->adapter->getExifFromFile($file); } } diff --git a/tests/PHPExif/Adapter/AdapterAbstractTest.php b/tests/PHPExif/Adapter/AdapterAbstractTest.php index 214878c..c3997e5 100644 --- a/tests/PHPExif/Adapter/AdapterAbstractTest.php +++ b/tests/PHPExif/Adapter/AdapterAbstractTest.php @@ -4,9 +4,6 @@ use PHPExif\Adapter\Exiftool; use PHPExif\Adapter\Native; -/** - * @covers \PHPExif\Adapter\AbstractAdapter:: - */ class AbstractAdapterTest extends PHPUnit\Framework\TestCase { /** @@ -21,7 +18,6 @@ protected function setUp(): void /** * @group adapter - * @covers \PHPExif\Adapter\AbstractAdapter::setOptions */ public function testSetOptionsReturnsCurrentInstance() { @@ -31,7 +27,6 @@ public function testSetOptionsReturnsCurrentInstance() /** * @group adapter - * @covers \PHPExif\Adapter\AbstractAdapter::setOptions */ public function testSetOptionsCorrectlySetsProperties() { @@ -51,7 +46,6 @@ public function testSetOptionsCorrectlySetsProperties() /** * @group adapter - * @covers \PHPExif\Adapter\AbstractAdapter::setOptions */ public function testSetOptionsIgnoresPropertiesWithoutSetters() { @@ -70,7 +64,6 @@ public function testSetOptionsIgnoresPropertiesWithoutSetters() /** * @group adapter - * @covers \PHPExif\Adapter\AbstractAdapter::__construct */ public function testConstructorSetsOptions() { @@ -90,7 +83,6 @@ public function testConstructorSetsOptions() /** * @group adapter - * @covers \PHPExif\Adapter\AbstractAdapter::setMapper */ public function testSetMapperReturnsCurrentInstance() { @@ -101,7 +93,6 @@ public function testSetMapperReturnsCurrentInstance() /** * @group adapter - * @covers \PHPExif\Adapter\AbstractAdapter::setMapper */ public function testSetMapperCorrectlySetsInProperty() { @@ -115,7 +106,6 @@ public function testSetMapperCorrectlySetsInProperty() /** * @group adapter - * @covers \PHPExif\Adapter\AbstractAdapter::getMapper */ public function testGetMapperCorrectlyReturnsFromProperty() { @@ -128,7 +118,6 @@ public function testGetMapperCorrectlyReturnsFromProperty() /** * @group adapter - * @covers \PHPExif\Adapter\AbstractAdapter::getMapper */ public function testGetMapperLazyLoadsMapperWhenNotPresent() { @@ -146,7 +135,6 @@ public function testGetMapperLazyLoadsMapperWhenNotPresent() /** * @group adapter - * @covers \PHPExif\Adapter\AbstractAdapter::getMapper */ public function testGetMapperLazyLoadingSetsInProperty() { @@ -170,7 +158,6 @@ public function testGetMapperLazyLoadingSetsInProperty() /** * @group adapter - * @covers \PHPExif\Adapter\AbstractAdapter::setHydrator */ public function testSetHydratorReturnsCurrentInstance() { @@ -181,7 +168,6 @@ public function testSetHydratorReturnsCurrentInstance() /** * @group adapter - * @covers \PHPExif\Adapter\AbstractAdapter::setHydrator */ public function testSetHydratorCorrectlySetsInProperty() { @@ -195,7 +181,6 @@ public function testSetHydratorCorrectlySetsInProperty() /** * @group adapter - * @covers \PHPExif\Adapter\AbstractAdapter::getHydrator */ public function testGetHydratorCorrectlyReturnsFromProperty() { @@ -208,7 +193,6 @@ public function testGetHydratorCorrectlyReturnsFromProperty() /** * @group adapter - * @covers \PHPExif\Adapter\AbstractAdapter::getHydrator */ public function testGetHydratorLazyLoadsHydratorWhenNotPresent() { @@ -218,7 +202,6 @@ public function testGetHydratorLazyLoadsHydratorWhenNotPresent() /** * @group adapter - * @covers \PHPExif\Adapter\AbstractAdapter::getHydrator */ public function testGetHydratorLazyLoadingSetsInProperty() { diff --git a/tests/PHPExif/Adapter/ExiftoolProcOpenTest.php b/tests/PHPExif/Adapter/ExiftoolProcOpenTest.php index ce81be1..520e796 100644 --- a/tests/PHPExif/Adapter/ExiftoolProcOpenTest.php +++ b/tests/PHPExif/Adapter/ExiftoolProcOpenTest.php @@ -1,16 +1,21 @@ - */ class ExiftoolProcOpenTest extends \PHPUnit\Framework\TestCase { /** * @var Exiftool */ - protected $adapter; + protected Exiftool $adapter; - public function setUp() : void + public function setUp(): void { global $mockProcOpen; $mockProcOpen = true; $this->adapter = new Exiftool(); } - public function tearDown() : void + public function tearDown(): void { global $mockProcOpen; $mockProcOpen = false; @@ -48,11 +50,10 @@ public function tearDown() : void /** * @group exiftool - * @covers Exiftool::getCliOutput */ public function testGetCliOutput() { - $this->expectException('RuntimeException'); + $this->expectException(PhpExifReaderException::class); $reflMethod = new \ReflectionMethod(Exiftool::class, 'getCliOutput'); $reflMethod->setAccessible(true); diff --git a/tests/PHPExif/Adapter/ExiftoolTest.php b/tests/PHPExif/Adapter/ExiftoolTest.php index f523f15..fa825d9 100644 --- a/tests/PHPExif/Adapter/ExiftoolTest.php +++ b/tests/PHPExif/Adapter/ExiftoolTest.php @@ -2,9 +2,6 @@ use PHPExif\Adapter\Exiftool; -/** - * @covers Exiftool:: - */ class ExiftoolTest extends \PHPUnit\Framework\TestCase { protected Exiftool $adapter; @@ -16,7 +13,6 @@ public function setUp(): void /** * @group exiftool - * @covers Exiftool::getToolPath */ public function testGetToolPathFromProperty() { @@ -30,7 +26,6 @@ public function testGetToolPathFromProperty() /** * @group exiftool - * @covers Exiftool::setToolPath */ public function testSetToolPathInProperty() { @@ -45,7 +40,6 @@ public function testSetToolPathInProperty() /** * @group exiftool - * @covers Exiftool::setToolPath */ public function testSetToolPathThrowsException() { @@ -56,7 +50,6 @@ public function testSetToolPathThrowsException() /** * @group exiftool - * @covers Exiftool::getToolPath */ public function testGetToolPathLazyLoadsPath() { @@ -65,7 +58,6 @@ public function testGetToolPathLazyLoadsPath() /** * @group exiftool - * @covers Exiftool::setNumeric */ public function testSetNumericInProperty() { @@ -81,7 +73,6 @@ public function testSetNumericInProperty() /** * @see URI http://www.sno.phy.queensu.ca/~phil/exiftool/faq.html#Q10 * @group exiftool - * @covers Exiftool::setEncoding */ public function testSetEncodingInProperty() { @@ -97,7 +88,6 @@ public function testSetEncodingInProperty() /** * @group exiftool - * @covers Exiftool::getExifFromFile */ public function testGetExifFromFile() { @@ -111,7 +101,6 @@ public function testGetExifFromFile() /** * @group exiftool - * @covers Exiftool::getExifFromFile */ public function testGetExifFromFileWithUtf8() { @@ -125,7 +114,6 @@ public function testGetExifFromFileWithUtf8() /** * @group exiftool - * @covers Exiftool::getCliOutput */ public function testGetCliOutput() { diff --git a/tests/PHPExif/Adapter/FFprobeTest.php b/tests/PHPExif/Adapter/FFprobeTest.php index 743ab55..5d0090a 100755 --- a/tests/PHPExif/Adapter/FFprobeTest.php +++ b/tests/PHPExif/Adapter/FFprobeTest.php @@ -2,26 +2,23 @@ use PHPExif\Adapter\FFprobe; use PHPExif\Exif; +use PHPExif\Reader\PhpExifReaderException; -/** - * @covers \PHPExif\Adapter\Native:: - */ class FFprobeTest extends \PHPUnit\Framework\TestCase { /** - * @var \PHPExif\Adapter\FFprobe + * @var FFprobe */ - protected $adapter; + protected FFprobe $adapter; public function setUp(): void { - $this->adapter = new \PHPExif\Adapter\FFprobe(); + $this->adapter = new FFprobe(); } /** * @group ffprobe - * @covers \PHPExif\Adapter\FFprobe::getToolPath */ public function testGetToolPathFromProperty() { @@ -35,7 +32,6 @@ public function testGetToolPathFromProperty() /** * @group ffprobe - * @covers \PHPExif\Adapter\FFprobe::setToolPath */ public function testSetToolPathInProperty() { @@ -50,7 +46,6 @@ public function testSetToolPathInProperty() /** * @group ffprobe - * @covers \PHPExif\Adapter\FFprobe::setToolPath */ public function testSetToolPathThrowsException() { @@ -60,7 +55,6 @@ public function testSetToolPathThrowsException() /** * @group ffprobe - * @covers \PHPExif\Adapter\FFprobe::getToolPath */ public function testGetToolPathLazyLoadsPath() { @@ -69,7 +63,6 @@ public function testGetToolPathLazyLoadsPath() /** * @group ffprobe - * @covers \PHPExif\Adapter\FFprobe::getExifFromFile */ public function testGetExifFromFileHasData() { @@ -88,12 +81,11 @@ public function testGetExifFromFileHasData() /** * @group ffprobe - * @covers \PHPExif\Adapter\FFprobe::getExifFromFile */ public function testErrorImageUsed() { $file = PHPEXIF_TEST_ROOT . '/files/morning_glory_pool_500.jpg'; - $this->expectException(RuntimeException::class); + $this->expectException(PhpExifReaderException::class); $this->adapter->getExifFromFile($file); } diff --git a/tests/PHPExif/Adapter/ImageMagickTest.php b/tests/PHPExif/Adapter/ImageMagickTest.php index 2c55e6b..f864712 100644 --- a/tests/PHPExif/Adapter/ImageMagickTest.php +++ b/tests/PHPExif/Adapter/ImageMagickTest.php @@ -3,15 +3,12 @@ use PHPExif\Adapter\ImageMagick; use PHPExif\Exif; -/** - * @covers ImageMagick:: - */ class ImageMagickTest extends \PHPUnit\Framework\TestCase { /** * @var ImageMagick */ - protected $adapter; + protected ImageMagick $adapter; public function setUp(): void { @@ -20,7 +17,6 @@ public function setUp(): void /** * @group ImageMagick - * @covers ImageMagick::getExifFromFile */ public function testGetExifFromFile() { @@ -33,7 +29,6 @@ public function testGetExifFromFile() /** * @group ImageMagick - * @covers ImageMagick::getIptcData */ public function testGetEmptyIptcData() { diff --git a/tests/PHPExif/Adapter/NativeTest.php b/tests/PHPExif/Adapter/NativeTest.php index 1443c12..df9d1af 100755 --- a/tests/PHPExif/Adapter/NativeTest.php +++ b/tests/PHPExif/Adapter/NativeTest.php @@ -2,15 +2,12 @@ use PHPExif\Adapter\Native; -/** - * @covers Native:: - */ class NativeTest extends \PHPUnit\Framework\TestCase { /** * @var Native */ - protected $adapter; + protected Native $adapter; public function setUp(): void { @@ -19,7 +16,6 @@ public function setUp(): void /** * @group native - * @covers Native::setIncludeThumbnail */ public function testSetIncludeThumbnailInProperty() { @@ -35,7 +31,6 @@ public function testSetIncludeThumbnailInProperty() /** * @group native - * @covers Native::getIncludeThumbnail */ public function testGetIncludeThumbnailFromProperty() { @@ -48,7 +43,6 @@ public function testGetIncludeThumbnailFromProperty() /** * @group native - * @covers Native::GetIncludeThumbnail */ public function testGetIncludeThumbnailHasDefaultValue() { @@ -57,7 +51,6 @@ public function testGetIncludeThumbnailHasDefaultValue() /** * @group native - * @covers Native::getRequiredSections */ public function testGetRequiredSections() { @@ -69,7 +62,6 @@ public function testGetRequiredSections() /** * @group native - * @covers Native::setRequiredSections */ public function testSetRequiredSections() { @@ -86,7 +78,6 @@ public function testSetRequiredSections() /** * @group native - * @covers Native::addRequiredSection */ public function testAddRequiredSection() { @@ -105,7 +96,6 @@ public function testAddRequiredSection() /** * @group native - * @covers Native::getExifFromFile */ public function testGetExifFromFileNoData() { @@ -119,7 +109,6 @@ public function testGetExifFromFileNoData() /** * @group native - * @covers Native::getExifFromFile */ public function testGetExifFromFileHasData() { @@ -132,7 +121,6 @@ public function testGetExifFromFileHasData() /** * @group native - * @covers Native::getIptcData */ public function testGetIptcData() { @@ -150,7 +138,6 @@ public function testGetIptcData() /** * @group native - * @covers Native::getIptcData */ public function testGetEmptyIptcData() { @@ -162,7 +149,6 @@ public function testGetEmptyIptcData() /** * @group native - * @covers Native::setSectionsAsArrays */ public function testSetSectionsAsArrayInProperty() { @@ -176,7 +162,6 @@ public function testSetSectionsAsArrayInProperty() /** * @group native - * @covers Native::setSectionsAsArrays */ public function testSetSectionsAsArrayConvertsToBoolean() { @@ -190,7 +175,6 @@ public function testSetSectionsAsArrayConvertsToBoolean() /** * @group native - * @covers Native::getSectionsAsArrays */ public function testGetSectionsAsArrayFromProperty() { diff --git a/tests/PHPExif/ExifTest.php b/tests/PHPExif/ExifTest.php index 095fcf3..ede787a 100755 --- a/tests/PHPExif/ExifTest.php +++ b/tests/PHPExif/ExifTest.php @@ -1,9 +1,7 @@ - */ + class ExifTest extends \PHPUnit\Framework\TestCase { /** @@ -21,7 +19,6 @@ public function setUp(): void /** * @group exif - * @covers Exif::__construct */ public function testConstructorCallsSetData() { @@ -47,7 +44,6 @@ public function testConstructorCallsSetData() /** * @group exif - * @covers Exif::getRawData */ public function testGetRawData() { @@ -59,7 +55,6 @@ public function testGetRawData() /** * @group exif - * @covers Exif::setRawData */ public function testSetRawData() { @@ -75,7 +70,6 @@ public function testSetRawData() /** * @group exif - * @covers Exif::getData */ public function testGetData() { @@ -87,7 +81,6 @@ public function testGetData() /** * @group exif - * @covers Exif::setData */ public function testSetData() { @@ -104,49 +97,6 @@ public function testSetData() /** * * @dataProvider providerUndefinedPropertiesReturnFalse - * @covers Exif::getAperture - * @covers Exif::getIso - * @covers Exif::getExposure - * @covers Exif::getExposureMilliseconds - * @covers Exif::getFocusDistance - * @covers Exif::getWidth - * @covers Exif::getHeight - * @covers Exif::getTitle - * @covers Exif::getCaption - * @covers Exif::getCopyright - * @covers Exif::getKeywords - * @covers Exif::getCamera - * @covers Exif::getHorizontalResolution - * @covers Exif::getVerticalResolution - * @covers Exif::getSoftware - * @covers Exif::getFocalLength - * @covers Exif::getCreationDate - * @covers Exif::getAuthor - * @covers Exif::getCredit - * @covers Exif::getSource - * @covers Exif::getJobtitle - * @covers Exif::getMimeType - * @covers Exif::getFileSize - * @covers Exif::getFileName - * @covers Exif::getHeadline - * @covers Exif::getColorSpace - * @covers Exif::getOrientation - * @covers Exif::getGPS - * @covers Exif::getDescription - * @covers Exif::getMake - * @covers Exif::getAltitude - * @covers Exif::getLatitude - * @covers Exif::getLongitude - * @covers Exif::getImgDirection - * @covers Exif::getLens - * @covers Exif::getContentIdentifier - * @covers Exif::getFramerate - * @covers Exif::getDuration - * @covers Exif::getMicroVideoOffset - * @covers Exif::getCity - * @covers Exif::getSublocation - * @covers Exif::getState - * @covers Exif::getCountry * @param string $accessor */ public function testUndefinedPropertiesReturnFalse($accessor) @@ -212,7 +162,6 @@ public function providerUndefinedPropertiesReturnFalse() /** * @group exif - * @covers Exif::getAperture */ public function testGetAperture() { @@ -225,7 +174,6 @@ public function testGetAperture() /** * @group exif - * @covers Exif::getIso */ public function testGetIso() { @@ -237,7 +185,6 @@ public function testGetIso() /** * @group exif - * @covers Exif::getExposure */ public function testGetExposure() { @@ -249,7 +196,6 @@ public function testGetExposure() /** * @group exif - * @covers Exif::getExposureMilliseconds */ public function testGetExposureMilliseconds() { @@ -270,7 +216,6 @@ public function testGetExposureMilliseconds() /** * @group exif - * @covers Exif::getFocusDistance */ public function testGetFocusDistance() { @@ -282,7 +227,6 @@ public function testGetFocusDistance() /** * @group exif - * @covers Exif::getWidth */ public function testGetWidth() { @@ -294,7 +238,6 @@ public function testGetWidth() /** * @group exif - * @covers Exif::getHeight */ public function testGetHeight() { @@ -306,7 +249,6 @@ public function testGetHeight() /** * @group exif - * @covers Exif::getTitle */ public function testGetTitle() { @@ -318,7 +260,6 @@ public function testGetTitle() /** * @group exif - * @covers Exif::getCaption */ public function testGetCaption() { @@ -330,7 +271,6 @@ public function testGetCaption() /** * @group exif - * @covers Exif::getCopyright */ public function testGetCopyright() { @@ -342,7 +282,6 @@ public function testGetCopyright() /** * @group exif - * @covers Exif::getKeywords */ public function testGetKeywords() { @@ -354,7 +293,6 @@ public function testGetKeywords() /** * @group exif - * @covers Exif::getCamera */ public function testGetCamera() { @@ -366,7 +304,6 @@ public function testGetCamera() /** * @group exif - * @covers Exif::getHorizontalResolution */ public function testGetHorizontalResolution() { @@ -378,7 +315,6 @@ public function testGetHorizontalResolution() /** * @group exif - * @covers Exif::getVerticalResolution */ public function testGetVerticalResolution() { @@ -390,7 +326,6 @@ public function testGetVerticalResolution() /** * @group exif - * @covers Exif::getSoftware */ public function testGetSoftware() { @@ -402,7 +337,6 @@ public function testGetSoftware() /** * @group exif - * @covers Exif::getFocalLength */ public function testGetFocalLength() { @@ -414,7 +348,6 @@ public function testGetFocalLength() /** * @group exif - * @covers Exif::getCreationDate */ public function testGetCreationDate() { @@ -427,7 +360,6 @@ public function testGetCreationDate() /** * @group exif - * @covers Exif::getAuthor */ public function testGetAuthor() { @@ -439,7 +371,6 @@ public function testGetAuthor() /** * @group exif - * @covers Exif::getHeadline */ public function testGetHeadline() { @@ -451,7 +382,6 @@ public function testGetHeadline() /** * @group exif - * @covers Exif::getCredit */ public function testGetCredit() { @@ -463,7 +393,6 @@ public function testGetCredit() /** * @group exif - * @covers Exif::getSource */ public function testGetSource() { @@ -475,7 +404,6 @@ public function testGetSource() /** * @group exif - * @covers Exif::getJobtitle */ public function testGetJobtitle() { @@ -487,7 +415,6 @@ public function testGetJobtitle() /** * @group exif - * @covers Exif::getColorSpace */ public function testGetColorSpace() { @@ -499,7 +426,6 @@ public function testGetColorSpace() /** * @group exif - * @covers Exif::getMimeType */ public function testGetMimeType() { @@ -511,7 +437,6 @@ public function testGetMimeType() /** * @group exif - * @covers Exif::getFileSize */ public function testGetFileSize() { @@ -523,7 +448,6 @@ public function testGetFileSize() /** * @group exif - * @covers Exif::getFileName */ public function testGetFileName() { @@ -535,7 +459,6 @@ public function testGetFileName() /** * @group exif - * @covers Exif::getOrientation */ public function testGetOrientation() { @@ -547,7 +470,6 @@ public function testGetOrientation() /** * @group exif - * @covers Exif::getGPS */ public function testGetGPS() { @@ -559,7 +481,6 @@ public function testGetGPS() /** * @group exif - * @covers Exif::getDescription */ public function testGetDescription() { @@ -571,7 +492,6 @@ public function testGetDescription() /** * @group exif - * @covers Exif::getMake */ public function testGetMake() { @@ -583,7 +503,6 @@ public function testGetMake() /** * @group exif - * @covers Exif::getAltitude */ public function testGetAltitude() { @@ -595,7 +514,6 @@ public function testGetAltitude() /** * @group exif - * @covers Exif::getLatitude */ public function testGetLatitude() { @@ -607,7 +525,6 @@ public function testGetLatitude() /** * @group exif - * @covers Exif::getLongitude */ public function testGetLongitude() { @@ -619,7 +536,6 @@ public function testGetLongitude() /** * @group exif - * @covers Exif::getImgDirection */ public function testGetImgDirection() { @@ -631,7 +547,6 @@ public function testGetImgDirection() /** * @group exif - * @covers Exif::getLens */ public function testGetLens() { @@ -643,7 +558,6 @@ public function testGetLens() /** * @group exif - * @covers Exif::getContentIdentifier */ public function testGetContentIdentifier() { @@ -655,7 +569,6 @@ public function testGetContentIdentifier() /** * @group exif - * @covers Exif::getFramerate */ public function testGetFramerate() { @@ -667,7 +580,6 @@ public function testGetFramerate() /** * @group exif - * @covers Exif::getDuration */ public function testGetDuration() { @@ -679,7 +591,6 @@ public function testGetDuration() /** * @group exif - * @covers Exif::getMicroVideoOffset */ public function testGetMicroVideoOffset() { @@ -691,7 +602,6 @@ public function testGetMicroVideoOffset() /** * @group exif - * @covers Exif::getCity */ public function testGetCity() { @@ -703,7 +613,6 @@ public function testGetCity() /** * @group exif - * @covers Exif::getSublocation */ public function testGetSublocation() { @@ -715,7 +624,6 @@ public function testGetSublocation() /** * @group exif - * @covers Exif::getState */ public function testGetState() { @@ -727,7 +635,6 @@ public function testGetState() /** * @group exif - * @covers Exif::getCountry */ public function testGetCountry() { @@ -739,48 +646,6 @@ public function testGetCountry() /** * @group exif - * @covers Exif::setAperture - * @covers Exif::setIso - * @covers Exif::setExposure - * @covers Exif::setFocusDistance - * @covers Exif::setWidth - * @covers Exif::setHeight - * @covers Exif::setTitle - * @covers Exif::setCaption - * @covers Exif::setCopyright - * @covers Exif::setKeywords - * @covers Exif::setCamera - * @covers Exif::setHorizontalResolution - * @covers Exif::setVerticalResolution - * @covers Exif::setSoftware - * @covers Exif::setFocalLength - * @covers Exif::setCreationDate - * @covers Exif::setAuthor - * @covers Exif::setCredit - * @covers Exif::setSource - * @covers Exif::setJobtitle - * @covers Exif::setMimeType - * @covers Exif::setFileSize - * @covers Exif::setFileName - * @covers Exif::setHeadline - * @covers Exif::setColorSpace - * @covers Exif::setOrientation - * @covers Exif::setGPS - * @covers Exif::setDescription - * @covers Exif::setMake - * @covers Exif::setAltitude - * @covers Exif::setLongitude - * @covers Exif::setLatitude - * @covers Exif::setImgDirection - * @covers Exif::setLens - * @covers Exif::setContentIdentifier - * @covers Exif::setFramerate - * @covers Exif::setDuration - * @covers Exif::setMicroVideoOffset - * @covers Exif::setCity - * @covers Exif::setSublocation - * @covers Exif::setState - * @covers Exif::setCountry */ public function testMutatorMethodsSetInProperty() { @@ -825,6 +690,7 @@ public function testMutatorMethodsSetInProperty() break; case 'focalDistance': $setter = 'setFocusDistance'; + // no break default: $this->exif->$setter($expected); $propertyValue = $reflProp->getValue($this->exif); @@ -838,29 +704,6 @@ public function testMutatorMethodsSetInProperty() * Test that the values returned by different adapters are equal * * @group consistency - * @covers Exif::getAperture - * @covers Exif::getIso - * @covers Exif::getExposure - * @covers Exif::getExposureMilliseconds - * @covers Exif::getFocusDistance - * @covers Exif::getWidth - * @covers Exif::getHeight - * @covers Exif::getTitle - * @covers Exif::getCaption - * @covers Exif::getCopyright - * @covers Exif::getKeywords - * @covers Exif::getCamera - * @covers Exif::getHorizontalResolution - * @covers Exif::getVerticalResolution - * @covers Exif::getSoftware - * @covers Exif::getFocalLength - * @covers Exif::getCreationDate - * @covers Exif::getAuthor - * @covers Exif::getCredit - * @covers Exif::getSource - * @covers Exif::getJobtitle - * @covers Exif::getMimeType - * @covers Exif::getFileSize */ public function testAdapterConsistency() { diff --git a/tests/PHPExif/Hydrator/MutatorTest.php b/tests/PHPExif/Hydrator/MutatorTest.php index 4270337..a267b72 100644 --- a/tests/PHPExif/Hydrator/MutatorTest.php +++ b/tests/PHPExif/Hydrator/MutatorTest.php @@ -2,9 +2,6 @@ use PhpExif\Hydrator\Mutator; -/** - * @covers Mutator:: - */ class MutatorTest extends \PHPUnit\Framework\TestCase { /** @@ -16,7 +13,6 @@ protected function setUp(): void /** * @group hydrator - * @covers Mutator::hydrate */ public function testHydrateCallsDetermineMutator() { @@ -42,7 +38,6 @@ public function testHydrateCallsDetermineMutator() /** * @group hydrator - * @covers Mutator::hydrate */ public function testHydrateCallsMutatorsOnObject() { @@ -61,13 +56,12 @@ public function testHydrateCallsMutatorsOnObject() ->with($this->equalTo($input['bar'])); // do the test - $hydrator = new Mutator; + $hydrator = new Mutator(); $hydrator->hydrate($mock, $input); } /** * @group hydrator - * @covers Mutator::hydrate */ public function testHydrateCallsEmptyValues() { @@ -88,7 +82,7 @@ public function testHydrateCallsEmptyValues() ->method('setBar'); // do the test - $hydrator = new Mutator; + $hydrator = new Mutator(); $hydrator->hydrate($mock, $input); } } diff --git a/tests/PHPExif/Mapper/ExiftoolMapperTest.php b/tests/PHPExif/Mapper/ExiftoolMapperTest.php index 377ab28..70dd0c4 100644 --- a/tests/PHPExif/Mapper/ExiftoolMapperTest.php +++ b/tests/PHPExif/Mapper/ExiftoolMapperTest.php @@ -3,16 +3,13 @@ use PHPExif\Contracts\MapperInterface; use PhpExif\Mapper\Exiftool; -/** - * @covers Exiftool:: - */ class ExiftoolMapperTest extends \PHPUnit\Framework\TestCase { protected $mapper; public function setUp(): void { - $this->mapper = new Exiftool; + $this->mapper = new Exiftool(); } /** @@ -25,7 +22,6 @@ public function testClassImplementsCorrectInterface() /** * @group mapper - * @covers Exiftool::mapRawData */ public function testMapRawDataIgnoresFieldIfItDoesntExist() { @@ -37,7 +33,6 @@ public function testMapRawDataIgnoresFieldIfItDoesntExist() /** * @group mapper - * @covers Exiftool::mapRawData */ public function testMapRawDataMapsFieldsCorrectly() { @@ -115,7 +110,6 @@ public function testMapRawDataMapsFieldsCorrectly() /** * @group mapper - * @covers Exiftool::mapRawData */ public function testMapRawDataCorrectlyFormatsAperture() { @@ -130,7 +124,6 @@ public function testMapRawDataCorrectlyFormatsAperture() /** * @group mapper - * @covers Exiftool::mapRawData */ public function testMapRawDataCorrectlyFormatsFocusDistance() { @@ -145,7 +138,6 @@ public function testMapRawDataCorrectlyFormatsFocusDistance() /** * @group mapper - * @covers Exiftool::mapRawData */ public function testMapRawDataCorrectlyFormatsCreationDate() { @@ -165,7 +157,6 @@ public function testMapRawDataCorrectlyFormatsCreationDate() /** * @group mapper - * @covers Exiftool::mapRawData */ public function testMapRawDataCorrectlyFormatsCreationDateWithTimeZone() { @@ -206,7 +197,6 @@ public function testMapRawDataCorrectlyFormatsCreationDateWithTimeZone() /** * @group mapper - * @covers Exiftool::mapRawData */ public function testMapRawDataCorrectlyFormatsCreationDateWithTimeZone2() { @@ -235,7 +225,6 @@ public function testMapRawDataCorrectlyFormatsCreationDateWithTimeZone2() /** * @group mapper - * @covers Exiftool::mapRawData */ public function testMapRawDataCorrectlyIgnoresIncorrectCreationDate() { @@ -250,7 +239,6 @@ public function testMapRawDataCorrectlyIgnoresIncorrectCreationDate() /** * @group mapper - * @covers Exiftool::mapRawData */ public function testMapRawDataCorrectlyIgnoresIncorrectCreationDate2() { @@ -265,7 +253,6 @@ public function testMapRawDataCorrectlyIgnoresIncorrectCreationDate2() /** * @group mapper - * @covers Exiftool::mapRawData */ public function testMapRawDataCorrectlyIgnoresIncorrectTimeZone() { @@ -286,7 +273,6 @@ public function testMapRawDataCorrectlyIgnoresIncorrectTimeZone() /** * @group mapper - * @covers Exiftool::mapRawData */ public function testMapRawDataCorrectlyFormatsExposureTime() { @@ -308,7 +294,6 @@ public function testMapRawDataCorrectlyFormatsExposureTime() /** * @group mapper - * @covers Exiftool::mapRawData */ public function testMapRawDataCorrectlyFormatsFocalLength() { @@ -323,7 +308,6 @@ public function testMapRawDataCorrectlyFormatsFocalLength() /** * @group mapper - * @covers Exiftool::mapRawData */ public function testMapRawDataCorrectlyFormatsGPSData() { @@ -348,7 +332,6 @@ public function testMapRawDataCorrectlyFormatsGPSData() /** * @group mapper - * @covers Exiftool::mapRawData */ public function testMapRawDataIncorrectlyFormatedGPSData() { @@ -367,7 +350,6 @@ public function testMapRawDataIncorrectlyFormatedGPSData() /** * @group mapper - * @covers Exiftool::mapRawData */ public function testMapRawDataCorrectlyFormatsNumericGPSData() { @@ -391,7 +373,6 @@ public function testMapRawDataCorrectlyFormatsNumericGPSData() /** * @group mapper - * @covers Exiftool::mapRawData */ public function testMapRawDataOnlyLatitude() { @@ -407,7 +388,6 @@ public function testMapRawDataOnlyLatitude() /** * @group mapper - * @covers Exiftool::mapRawData */ public function testMapRawDataCorrectlyIgnoresEmptyGPSData() { @@ -425,7 +405,6 @@ public function testMapRawDataCorrectlyIgnoresEmptyGPSData() /** * @group mapper - * @covers Exiftool::mapRawData */ public function testMapRawDataCorrectlyIgnoresIncorrectImageDirection() { @@ -440,7 +419,6 @@ public function testMapRawDataCorrectlyIgnoresIncorrectImageDirection() /** * @group mapper - * @covers Exiftool::mapRawData */ public function testMapRawDataCorrectImageDirection() { @@ -455,7 +433,6 @@ public function testMapRawDataCorrectImageDirection() /** * @group mapper - * @covers Exiftool::setNumeric */ public function testSetNumericInProperty() { @@ -505,7 +482,6 @@ public function testMapRawDataCorrectlyIgnoresInvalidCreateDate() /** * @group mapper - * @covers Exiftool::mapRawData */ public function testMapRawDataCorrectlyAltitude() { @@ -521,7 +497,6 @@ public function testMapRawDataCorrectlyAltitude() /** * @group mapper - * @covers Exiftool::mapRawData */ public function testMapRawDataCorrectlyNegativeAltitude() { @@ -537,7 +512,6 @@ public function testMapRawDataCorrectlyNegativeAltitude() /** * @group mapper - * @covers Exiftool::mapRawData */ public function testMapRawDataCorrectlyIgnoresIncorrectAltitude() { @@ -552,7 +526,6 @@ public function testMapRawDataCorrectlyIgnoresIncorrectAltitude() /** * @group mapper - * @covers Exiftool::mapRawData */ public function testMapRawDataCorrectlyFormatsQuicktimeGPSData() { @@ -575,7 +548,6 @@ public function testMapRawDataCorrectlyFormatsQuicktimeGPSData() /** * @group mapper - * @covers Exiftool::mapRawData */ public function testMapRawDataCorrectlyQuicktimeAltitude() { @@ -591,7 +563,6 @@ public function testMapRawDataCorrectlyQuicktimeAltitude() /** * @group mapper - * @covers Exiftool::mapRawData */ public function testMapRawDataCorrectlyHeightVideo() { @@ -636,7 +607,6 @@ public function testMapRawDataCorrectlyHeightVideo() /** * @group mapper - * @covers Exiftool::mapRawData */ public function testMapRawDataCorrectlyWidthVideo() { @@ -680,7 +650,6 @@ public function testMapRawDataCorrectlyWidthVideo() /** * @group mapper - * @covers Exiftool::mapRawData */ public function testMapRawDataCorrectlyIsoFormats() { @@ -701,7 +670,6 @@ public function testMapRawDataCorrectlyIsoFormats() /** * @group mapper - * @covers Exiftool::mapRawData */ public function testMapRawDataCorrectlyLensData() { @@ -731,7 +699,6 @@ public function testMapRawDataCorrectlyLensData() /** * @group mapper - * @covers Exiftool::mapRawData */ public function testMapRawDataCorrectlyLensData2() { @@ -749,7 +716,6 @@ public function testMapRawDataCorrectlyLensData2() /** * @group mapper - * @covers Exiftool::mapRawData */ public function testMapRawDataCorrectlyKeywords() { @@ -767,7 +733,6 @@ public function testMapRawDataCorrectlyKeywords() /** * @group mapper - * @covers Exiftool::mapRawData */ public function testMapRawDataCorrectlyKeywordsAndSubject() { diff --git a/tests/PHPExif/Mapper/FFprobeMapperTest.php b/tests/PHPExif/Mapper/FFprobeMapperTest.php index d5c2976..dcc6869 100644 --- a/tests/PHPExif/Mapper/FFprobeMapperTest.php +++ b/tests/PHPExif/Mapper/FFprobeMapperTest.php @@ -4,9 +4,6 @@ use PHPExif\Contracts\MapperInterface; use PHPExif\Mapper\FFprobe; -/** - * @covers FFprobe:: - */ class FFprobeMapperTest extends \PHPUnit\Framework\TestCase { protected $mapper; @@ -26,7 +23,6 @@ public function testClassImplementsCorrectInterface() /** * @group mapper - * @covers FFprobe::mapRawData */ public function testMapRawDataIgnoresFieldIfItDoesntExist() { @@ -38,7 +34,6 @@ public function testMapRawDataIgnoresFieldIfItDoesntExist() /** * @group mapper - * @covers FFprobe::mapRawData */ public function testMapRawDataMapsFieldsCorrectly() { @@ -83,7 +78,6 @@ public function testMapRawDataMapsFieldsCorrectly() /** * @group mapper - * @covers FFprobe::mapRawData */ public function testMapRawDataCorrectlyFormatsDateTimeOriginal() { @@ -104,7 +98,6 @@ public function testMapRawDataCorrectlyFormatsDateTimeOriginal() /** * @group mapper - * @covers FFprobe::mapRawData */ public function testMapRawDataCorrectlyFormatsCreationDateQuicktime() { @@ -133,7 +126,6 @@ public function testMapRawDataCorrectlyFormatsCreationDateQuicktime() /** * @group mapper - * @covers FFprobe::mapRawData */ public function testMapRawDataCorrectlyFormatsCreationDateWithTimeZone() { @@ -161,7 +153,6 @@ public function testMapRawDataCorrectlyFormatsCreationDateWithTimeZone() /** * @group mapper - * @covers FFprobe::mapRawData */ public function testMapRawDataCorrectlyIgnoresIncorrectDateTimeOriginal() { @@ -176,7 +167,6 @@ public function testMapRawDataCorrectlyIgnoresIncorrectDateTimeOriginal() /** * @group mapper - * @covers FFprobe::mapRawData */ public function testMapRawDataCorrectlyIgnoresIncorrectDateTimeOriginal2() { @@ -191,7 +181,6 @@ public function testMapRawDataCorrectlyIgnoresIncorrectDateTimeOriginal2() /** * @group mapper - * @covers FFprobe::mapRawData */ public function testMapRawDataCorrectlyFormatsQuickTimeGPSData() { @@ -205,9 +194,9 @@ public function testMapRawDataCorrectlyFormatsQuickTimeGPSData() foreach ($expected as $key => $value) { - $result = $this->mapper->mapRawData(array('com.apple.quicktime.location.ISO6709' => $key)); + $result = $this->mapper->mapRawData(array('com.apple.quicktime.location.ISO6709' => $key)); - $this->assertEquals($value[\PHPExif\Exif::LATITUDE], $result[\PHPExif\Exif::LATITUDE]); + $this->assertEquals($value[\PHPExif\Exif::LATITUDE], $result[\PHPExif\Exif::LATITUDE]); $this->assertEquals($value[\PHPExif\Exif::LONGITUDE], $result[\PHPExif\Exif::LONGITUDE]); $this->assertEquals($value[\PHPExif\Exif::ALTITUDE], $result[\PHPExif\Exif::ALTITUDE]); } @@ -215,7 +204,6 @@ public function testMapRawDataCorrectlyFormatsQuickTimeGPSData() /** * @group mapper - * @covers FFprobe::mapRawData */ public function testMapRawDataCorrectlyRotatesDimensions() { @@ -229,15 +217,14 @@ public function testMapRawDataCorrectlyRotatesDimensions() foreach ($expected as $key => $value) { - $result = $this->mapper->mapRawData($value); + $result = $this->mapper->mapRawData($value); - $this->assertEquals($key, $result[\PHPExif\Exif::WIDTH]); + $this->assertEquals($key, $result[\PHPExif\Exif::WIDTH]); } } /** * @group mapper - * @covers FFprobe::mapRawData */ public function testMapRawDataCorrectlyFormatsGPSData() { @@ -254,14 +241,13 @@ public function testMapRawDataCorrectlyFormatsGPSData() ); foreach ($expected as $key => $value) { - $result = $this->mapper->mapRawData($value); - $this->assertEquals($key, $result[\PHPExif\Exif::GPS]); + $result = $this->mapper->mapRawData($value); + $this->assertEquals($key, $result[\PHPExif\Exif::GPS]); } } /** * @group mapper - * @covers FFprobe::mapRawData */ public function testMapRawDataCorrectlyFramerate() { @@ -275,8 +261,8 @@ public function testMapRawDataCorrectlyFramerate() ); foreach ($expected as $key => $value) { - $result = $this->mapper->mapRawData($value); - $this->assertEquals($key, reset($result)); + $result = $this->mapper->mapRawData($value); + $this->assertEquals($key, reset($result)); } } @@ -317,7 +303,6 @@ public function testMapRawDataCorrectlyIgnoresInvalidCreateDate() /** * @group mapper - * @covers FFprobe::normalizeComponent */ public function testNormalizeComponentCorrectly() { @@ -345,7 +330,6 @@ public function testNormalizeComponentCorrectly() /** * @group mapper - * @covers \PHPExif\Mapper\Native::mapRawData */ public function testMapRawDataMatchesFieldsWithoutCaseSensibilityOnFirstLetter() { @@ -366,7 +350,6 @@ public function testMapRawDataMatchesFieldsWithoutCaseSensibilityOnFirstLetter() /** * @group mapper - * @covers FFprobe::readISO6709 */ public function testreadISO6709() { @@ -422,14 +405,13 @@ public function testreadISO6709() ); foreach ($testcase as $key => $expected) { - $result = $reflMethod->invoke($this->mapper, $key); - $this->assertEquals($expected, $result); + $result = $reflMethod->invoke($this->mapper, $key); + $this->assertEquals($expected, $result); } } /** * @group mapper - * @covers FFprobe::convertDMStoDecimal */ public function testconvertDMStoDecimal() { @@ -496,8 +478,8 @@ public function testconvertDMStoDecimal() ), ); foreach ($testcase as $expected => $key) { - $result = $reflMethod->invoke($this->mapper, $key['sign'], $key['degrees'],$key['minutes'],$key['seconds'],$key['fraction']); - $this->assertEquals($expected, $result); + $result = $reflMethod->invoke($this->mapper, $key['sign'], $key['degrees'], $key['minutes'], $key['seconds'], $key['fraction']); + $this->assertEquals($expected, $result); } } } diff --git a/tests/PHPExif/Mapper/ImageMagickMapperTest.php b/tests/PHPExif/Mapper/ImageMagickMapperTest.php index 6e89eb5..8eaa9ed 100644 --- a/tests/PHPExif/Mapper/ImageMagickMapperTest.php +++ b/tests/PHPExif/Mapper/ImageMagickMapperTest.php @@ -3,16 +3,13 @@ use PHPExif\Contracts\MapperInterface; use PHPExif\Mapper\ImageMagick; -/** - * @covers ImageMagick:: - */ class ImageMagickMapperTest extends \PHPUnit\Framework\TestCase { protected $mapper; public function setUp(): void { - $this->mapper = new ImageMagick; + $this->mapper = new ImageMagick(); } /** @@ -25,7 +22,6 @@ public function testClassImplementsCorrectInterface() /** * @group mapper - * @covers ImageMagick::mapRawData */ public function testMapRawDataIgnoresFieldIfItDoesntExist() { @@ -37,7 +33,6 @@ public function testMapRawDataIgnoresFieldIfItDoesntExist() /** * @group mapper - * @covers ImageMagick::mapRawData */ public function testMapRawDataMapsFieldsCorrectly() { @@ -78,7 +73,6 @@ public function testMapRawDataMapsFieldsCorrectly() /** * @group mapper - * @covers ImageMagick::mapRawData */ public function testMapRawDataCorrectlyFormatsAperture() { @@ -93,7 +87,6 @@ public function testMapRawDataCorrectlyFormatsAperture() /** * @group mapper - * @covers ImageMagick::mapRawData */ public function testMapRawDataCorrectlyFormatsCreationDate() { @@ -113,7 +106,6 @@ public function testMapRawDataCorrectlyFormatsCreationDate() /** * @group mapper - * @covers ImageMagick::mapRawData */ public function testMapRawDataCorrectlyFormatsDateTimeOriginal() { @@ -133,7 +125,6 @@ public function testMapRawDataCorrectlyFormatsDateTimeOriginal() /** * @group mapper - * @covers ImageMagick::mapRawData */ public function testMapRawDataCorrectlyFormatsCreationDateAndDateTimeOriginal1() { @@ -155,7 +146,6 @@ public function testMapRawDataCorrectlyFormatsCreationDateAndDateTimeOriginal1() /** * @group mapper - * @covers ImageMagick::mapRawData */ public function testMapRawDataCorrectlyFormatsCreationDateAndDateTimeOriginal2() { @@ -177,11 +167,10 @@ public function testMapRawDataCorrectlyFormatsCreationDateAndDateTimeOriginal2() /** * @group mapper - * @covers ImageMagick::mapRawData */ public function testMapRawDataCorrectlyFormatsCreationDateWithTimeZone() { - $data = array ( + $data = array( array( ImageMagick::DATETIMEORIGINAL => '2015:04:01 12:11:09+0200', ), @@ -218,7 +207,6 @@ public function testMapRawDataCorrectlyFormatsCreationDateWithTimeZone() /** * @group mapper - * @covers ImageMagick::mapRawData */ public function testMapRawDataCorrectlyFormatsCreationDateWithTimeZone2() { @@ -247,7 +235,6 @@ public function testMapRawDataCorrectlyFormatsCreationDateWithTimeZone2() /** * @group mapper - * @covers ImageMagick::mapRawData */ public function testMapRawDataCorrectlyIgnoresIncorrectCreationDate() { @@ -263,7 +250,6 @@ public function testMapRawDataCorrectlyIgnoresIncorrectCreationDate() /** * @group mapper - * @covers ImageMagick::mapRawData */ public function testMapRawDataCorrectlyIgnoresIncorrectDateTimeOriginal() { @@ -278,7 +264,6 @@ public function testMapRawDataCorrectlyIgnoresIncorrectDateTimeOriginal() /** * @group mapper - * @covers ImageMagick::mapRawData */ public function testMapRawDataCorrectlyIgnoresIncorrectTimeZone() { @@ -299,7 +284,6 @@ public function testMapRawDataCorrectlyIgnoresIncorrectTimeZone() /** * @group mapper - * @covers ImageMagick::mapRawData */ public function testMapRawDataCorrectlyFormatsExposureTime() { @@ -321,7 +305,6 @@ public function testMapRawDataCorrectlyFormatsExposureTime() /** * @group mapper - * @covers ImageMagick::mapRawData */ public function testMapRawDataCorrectlyFormatsFocalLength() { @@ -336,7 +319,6 @@ public function testMapRawDataCorrectlyFormatsFocalLength() /** * @group mapper - * @covers ImageMagick::mapRawData */ public function testMapRawDataCorrectlyFormatsGPSData() { @@ -359,7 +341,6 @@ public function testMapRawDataCorrectlyFormatsGPSData() /** * @group mapper - * @covers ImageMagick::mapRawData */ public function testMapRawDataIncorrectlyFormatedGPSData() { @@ -376,7 +357,6 @@ public function testMapRawDataIncorrectlyFormatedGPSData() /** * @group mapper - * @covers ImageMagick::mapRawData */ public function testMapRawDataCorrectlyFormatsNumericGPSData() { @@ -400,7 +380,6 @@ public function testMapRawDataCorrectlyFormatsNumericGPSData() /** * @group mapper - * @covers ImageMagick::mapRawData */ public function testMapRawDataOnlyLatitude() { @@ -416,7 +395,6 @@ public function testMapRawDataOnlyLatitude() /** * @group mapper - * @covers ImageMagick::mapRawData */ public function testMapRawDataCorrectlyIgnoresEmptyGPSData() { @@ -470,7 +448,6 @@ public function testMapRawDataCorrectlyIgnoresInvalidCreateDate() /** * @group mapper - * @covers ImageMagick::mapRawData */ public function testMapRawDataCorrectlyAltitude() { @@ -486,7 +463,6 @@ public function testMapRawDataCorrectlyAltitude() /** * @group mapper - * @covers ImageMagick::mapRawData */ public function testMapRawDataCorrectlyNegativeAltitude() { @@ -502,7 +478,6 @@ public function testMapRawDataCorrectlyNegativeAltitude() /** * @group mapper - * @covers ImageMagick::mapRawData */ public function testMapRawDataCorrectlyIgnoresIncorrectAltitude() { @@ -518,8 +493,7 @@ public function testMapRawDataCorrectlyIgnoresIncorrectAltitude() /** * @group mapper - * @covers ImageMagick::mapRawData - */ + */ public function testMapRawDataCorrectlyIsoFormats() { $expected = array( @@ -542,49 +516,46 @@ public function testMapRawDataCorrectlyIsoFormats() /** * @group mapper - * @covers ImageMagick::mapRawData - */ + */ public function testMapRawDataCorrectlyHeightPNG() { - $rawData = array( - '600' => array( - ImageMagick::IMAGEHEIGHT_PNG => '800, 600', - ), - ); + $rawData = array( + '600' => array( + ImageMagick::IMAGEHEIGHT_PNG => '800, 600', + ), + ); - foreach ($rawData as $expected => $value) { - $mapped = $this->mapper->mapRawData($value); + foreach ($rawData as $expected => $value) { + $mapped = $this->mapper->mapRawData($value); - $this->assertEquals($expected, $mapped['height']); - } + $this->assertEquals($expected, $mapped['height']); + } } /** * @group mapper - * @covers ImageMagick::mapRawData - */ + */ public function testMapRawDataCorrectlyWidthPNG() { - $rawData = array( - '800' => array( - ImageMagick::IMAGEWIDTH_PNG => '800, 600', - ), - ); + $rawData = array( + '800' => array( + ImageMagick::IMAGEWIDTH_PNG => '800, 600', + ), + ); - foreach ($rawData as $expected => $value) { - $mapped = $this->mapper->mapRawData($value); + foreach ($rawData as $expected => $value) { + $mapped = $this->mapper->mapRawData($value); - $this->assertEquals($expected, $mapped['width']); - } + $this->assertEquals($expected, $mapped['width']); + } } /** * @group mapper - * @covers ImageMagick::normalizeComponent */ public function testNormalizeComponentCorrectly() { @@ -612,7 +583,6 @@ public function testNormalizeComponentCorrectly() /** * @group mapper - * @covers ImageMagick::mapRawData */ public function testMapRawDataCorrectlyKeywords() { @@ -630,7 +600,6 @@ public function testMapRawDataCorrectlyKeywords() /** * @group mapper - * @covers ImageMagick::mapRawData */ public function testMapRawDataCorrectlyKeywordsAndSubject() { @@ -648,7 +617,6 @@ public function testMapRawDataCorrectlyKeywordsAndSubject() /** * @group mapper - * @covers ImageMagick::mapRawData */ public function testMapRawDataCorrectlyFormatsXResolution() { @@ -663,7 +631,6 @@ public function testMapRawDataCorrectlyFormatsXResolution() /** * @group mapper - * @covers ImageMagick::mapRawData */ public function testMapRawDataCorrectlyFormatsYResolution() { diff --git a/tests/PHPExif/Mapper/NativeMapperTest.php b/tests/PHPExif/Mapper/NativeMapperTest.php index 0aef40e..8778e35 100644 --- a/tests/PHPExif/Mapper/NativeMapperTest.php +++ b/tests/PHPExif/Mapper/NativeMapperTest.php @@ -3,16 +3,13 @@ use PHPExif\Contracts\MapperInterface; use PHPExif\Mapper\Native; -/** - * @covers Native:: - */ class NativeMapperTest extends \PHPUnit\Framework\TestCase { protected $mapper; public function setUp(): void { - $this->mapper = new Native; + $this->mapper = new Native(); } /** @@ -25,7 +22,6 @@ public function testClassImplementsCorrectInterface() /** * @group mapper - * @covers Native::mapRawData */ public function testMapRawDataIgnoresFieldIfItDoesntExist() { @@ -37,7 +33,6 @@ public function testMapRawDataIgnoresFieldIfItDoesntExist() /** * @group mapper - * @covers Native::mapRawData */ public function testMapRawDataMapsFieldsCorrectly() { @@ -80,7 +75,6 @@ public function testMapRawDataMapsFieldsCorrectly() /** * @group mapper - * @covers Native::mapRawData */ public function testMapRawDataCorrectlyFormatsDateTimeOriginal() { @@ -101,8 +95,7 @@ public function testMapRawDataCorrectlyFormatsDateTimeOriginal() /** * @group mapper - * @covers Native::mapRawData - */ + */ public function testMapRawDataCorrectlyFormatsCreationDateWithTimeZone() { $rawData = array( @@ -129,8 +122,7 @@ public function testMapRawDataCorrectlyFormatsCreationDateWithTimeZone() /** * @group mapper - * @covers Native::mapRawData - */ + */ public function testMapRawDataCorrectlyFormatsCreationDateWithTimeZone2() { $rawData = array( @@ -158,7 +150,6 @@ public function testMapRawDataCorrectlyFormatsCreationDateWithTimeZone2() /** * @group mapper - * @covers Native::mapRawData */ public function testMapRawDataCorrectlyIgnoresIncorrectDateTimeOriginal() { @@ -173,7 +164,6 @@ public function testMapRawDataCorrectlyIgnoresIncorrectDateTimeOriginal() /** * @group mapper - * @covers Native::mapRawData */ public function testMapRawDataCorrectlyIgnoresIncorrectTimeZone() { @@ -194,7 +184,6 @@ public function testMapRawDataCorrectlyIgnoresIncorrectTimeZone() /** * @group mapper - * @covers Native::mapRawData */ public function testMapRawDataCorrectlyFormatsExposureTime() { @@ -216,7 +205,6 @@ public function testMapRawDataCorrectlyFormatsExposureTime() /** * @group mapper - * @covers Native::mapRawData */ public function testMapRawDataCorrectlyFormatsFocalLength() { @@ -231,7 +219,6 @@ public function testMapRawDataCorrectlyFormatsFocalLength() /** * @group mapper - * @covers Native::mapRawData */ public function testMapRawDataCorrectlyFormatsFocalLengthDivisionByZero() { @@ -246,7 +233,6 @@ public function testMapRawDataCorrectlyFormatsFocalLengthDivisionByZero() /** * @group mapper - * @covers Native::mapRawData */ public function testMapRawDataCorrectlyFormatsXResolution() { @@ -261,7 +247,6 @@ public function testMapRawDataCorrectlyFormatsXResolution() /** * @group mapper - * @covers Native::mapRawData */ public function testMapRawDataCorrectlyFormatsYResolution() { @@ -276,7 +261,6 @@ public function testMapRawDataCorrectlyFormatsYResolution() /** * @group mapper - * @covers Native::mapRawData */ public function testMapRawDataFlattensRawDataWithSections() { @@ -299,7 +283,6 @@ public function testMapRawDataFlattensRawDataWithSections() /** * @group mapper - * @covers Native::mapRawData */ public function testMapRawDataMatchesFieldsWithoutCaseSensibilityOnFirstLetter() { @@ -320,7 +303,6 @@ public function testMapRawDataMatchesFieldsWithoutCaseSensibilityOnFirstLetter() /** * @group mapper - * @covers Native::mapRawData */ public function testMapRawDataCorrectlyFormatsGPSData() { @@ -353,7 +335,6 @@ public function testMapRawDataCorrectlyFormatsGPSData() /** * @group mapper - * @covers Native::mapRawData */ public function testMapRawDataCorrectlyIgnoresEmptyGPSData() { @@ -371,7 +352,6 @@ public function testMapRawDataCorrectlyIgnoresEmptyGPSData() /** * @group mapper - * @covers Native::mapRawData */ public function testMapRawDataCorrectlyFormatsAltitudeData() { @@ -394,7 +374,6 @@ public function testMapRawDataCorrectlyFormatsAltitudeData() /** * @group mapper - * @covers Native::mapRawData */ public function testMapRawDataCorrectlyIgnoresIncorrectAltitude() { @@ -444,7 +423,6 @@ public function testMapRawDataCorrectlyIgnoresInvalidCreateDate() /** * @group mapper - * @covers Native::normalizeComponent */ public function testNormalizeComponentCorrectly() { @@ -471,7 +449,6 @@ public function testNormalizeComponentCorrectly() /** * @group mapper - * @covers Native::mapRawData */ public function testMapRawDataCorrectlyIsoFormats() { @@ -495,11 +472,10 @@ public function testMapRawDataCorrectlyIsoFormats() /** * @group mapper - * @covers Native::mapRawData */ public function testMapRawDataCorrectlyLensData() { - $data = array ( + $data = array( array( Native::LENS => 'LEICA DG 12-60/F2.8-4.0', ), @@ -530,11 +506,10 @@ public function testMapRawDataCorrectlyLensData() /** * @group mapper - * @covers Native::mapRawData */ public function testMapRawDataCorrectlyLensData2() { - $data = array ( + $data = array( array( Native::LENS_LR => 'LUMIX G VARIO 12-32/F3.5-5.6', ), @@ -555,7 +530,6 @@ public function testMapRawDataCorrectlyLensData2() /** * @group mapper - * @covers Native::mapRawData */ public function testMapRawDataCorrectlyKeywords() { @@ -573,7 +547,6 @@ public function testMapRawDataCorrectlyKeywords() /** * @group mapper - * @covers Native::mapRawData */ public function testMapRawDataCorrectlyKeywordsAndSubject() { diff --git a/tests/PHPExif/Reader/ReaderTest.php b/tests/PHPExif/Reader/ReaderTest.php index a60d77d..243fcee 100644 --- a/tests/PHPExif/Reader/ReaderTest.php +++ b/tests/PHPExif/Reader/ReaderTest.php @@ -8,117 +8,59 @@ use PHPExif\Exif; use PHPExif\Reader\Reader; -/** - * @covers \PHPExif\Reader\Reader:: - * @covers \PHPExif\Adapter\NoAdapterException - */ class ReaderTest extends \PHPUnit\Framework\TestCase { - /** - * @var \PHPExif\Reader\Reader - */ - protected Reader $reader; - - /** - * Setup function before the tests - */ - public function setUp() : void - { - /** @var \PHPExif\Contracts\AdapterInterface */ - $adapter = $this->getMockBuilder(AdapterInterface::class)->getMockForAbstractClass(); - $this->reader = new \PHPExif\Reader\Reader($adapter); - } - /** * @group reader - * @covers \PHPExif\Reader\Reader::__construct */ public function testConstructorWithAdapter() { - /** @var \PHPExif\Contracts\AdapterInterface */ + /** @var AdapterInterface $mock */ $mock = $this->getMockBuilder(AdapterInterface::class)->getMockForAbstractClass(); $reflProperty = new \ReflectionProperty(Reader::class, 'adapter'); $reflProperty->setAccessible(true); - $reader = new \PHPExif\Reader\Reader($mock); + $reader = new Reader($mock); $this->assertSame($mock, $reflProperty->getValue($reader)); } /** * @group reader - * @covers \PHPExif\Reader\Reader::getAdapter - */ - public function testGetAdapterFromProperty() - { - $mock = $this->getMockBuilder(AdapterInterface::class)->getMockForAbstractClass(); - - $reflProperty = new \ReflectionProperty(Reader::class, 'adapter'); - $reflProperty->setAccessible(true); - $reflProperty->setValue($this->reader, $mock); - - $this->assertSame($mock, $this->reader->getAdapter()); - } - - /** - * @group reader - * @covers \PHPExif\Reader\Reader::getAdapter - * @covers \PHPExif\Adapter\NoAdapterException - */ - public function testGetAdapterThrowsExceptionWhenNoAdapterIsSet() - { - $this->expectException('\PHPExif\Adapter\NoAdapterException'); - $reflProperty = new \ReflectionProperty(Reader::class, 'adapter'); - $reflProperty->setAccessible(true); - $reflProperty->setValue($this->reader, null); - - $this->reader->getAdapter(); - } - - /** - * @group reader - * @covers \PHPExif\Reader\Reader::read */ public function testGetExifPassedToAdapter() { $adapter = $this->getMockBuilder(AdapterInterface::class)->getMockForAbstractClass(); $adapter->expects($this->once())->method('getExifFromFile'); - - $reflProperty = new \ReflectionProperty(Reader::class, 'adapter'); - $reflProperty->setAccessible(true); - $reflProperty->setValue($this->reader, $adapter); - - $this->reader->read('/tmp/foo.bar'); + $reader = new Reader($adapter); + $reader->read('/tmp/foo.bar'); } /** * @group reader - * @covers \PHPExif\Reader\Reader::factory */ public function testFactoryThrowsException() { $this->expectException('TypeError'); - \PHPExif\Reader\Reader::factory('foo'); + Reader::factory('foo'); } /** * @group reader - * @covers \PHPExif\Reader\Reader::factory */ public function testFactoryReturnsCorrectType() { - $reader = \PHPExif\Reader\Reader::factory(\PHPExif\Enum\ReaderType::NATIVE); + $reader = Reader::factory(\PHPExif\Enum\ReaderType::NATIVE); $this->assertInstanceOf(Reader::class, $reader); } /** * @group reader - * @covers \PHPExif\Reader\Reader::factory */ public function testFactoryAdapterTypeNative() { - $reader = \PHPExif\Reader\Reader::factory(\PHPExif\Enum\ReaderType::NATIVE); + $reader = Reader::factory(\PHPExif\Enum\ReaderType::NATIVE); $reflProperty = new \ReflectionProperty(Reader::class, 'adapter'); $reflProperty->setAccessible(true); @@ -129,11 +71,10 @@ public function testFactoryAdapterTypeNative() /** * @group reader - * @covers \PHPExif\Reader\Reader::factory */ public function testFactoryAdapterTypeExiftool() { - $reader = \PHPExif\Reader\Reader::factory(\PHPExif\Enum\ReaderType::EXIFTOOL); + $reader = Reader::factory(\PHPExif\Enum\ReaderType::EXIFTOOL); $reflProperty = new \ReflectionProperty(Reader::class, 'adapter'); $reflProperty->setAccessible(true); @@ -144,11 +85,10 @@ public function testFactoryAdapterTypeExiftool() /** * @group reader - * @covers \PHPExif\Reader\Reader::factory */ public function testFactoryAdapterTypeFFprobe() { - $reader = \PHPExif\Reader\Reader::factory(\PHPExif\Enum\ReaderType::FFPROBE); + $reader = Reader::factory(\PHPExif\Enum\ReaderType::FFPROBE); $reflProperty = new \ReflectionProperty(Reader::class, 'adapter'); $reflProperty->setAccessible(true); @@ -160,11 +100,10 @@ public function testFactoryAdapterTypeFFprobe() /** * @group reader - * @covers \PHPExif\Reader\Reader::factory */ public function testFactoryAdapterTypeImageMagick() { - $reader = \PHPExif\Reader\Reader::factory(\PHPExif\Enum\ReaderType::IMAGICK); + $reader = Reader::factory(\PHPExif\Enum\ReaderType::IMAGICK); $reflProperty = new \ReflectionProperty(Reader::class, 'adapter'); $reflProperty->setAccessible(true); @@ -172,28 +111,4 @@ public function testFactoryAdapterTypeImageMagick() $this->assertInstanceOf(ImageMagick::class, $adapter); } - - /** - * @group reader - * @covers \PHPExif\Reader\Reader::getExifFromFile - */ - public function testGetExifFromFileCallsReadMethod() - { - /** @var MockObject $mock */ - $mock = $this->getMockBuilder(Reader::class) - ->onlyMethods(array('read')) - ->disableOriginalConstructor() - ->getMock(); - - $expected = '/foo/bar/baz'; - $expectedResult = new Exif([]); - - $mock->expects($this->once()) - ->method('read') - ->with($this->equalTo($expected)) - ->will($this->returnValue($expectedResult)); - - $result = $mock->getExifFromFile($expected); - $this->assertEquals($expectedResult, $result); - } } diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 7cd9016..c57e707 100755 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -1,4 +1,5 @@