From 2c83129e248150c61c4e24cac658e67c5bbc213f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ewilan=20Rivi=C3=A8re?= Date: Thu, 3 Oct 2024 18:47:46 +0200 Subject: [PATCH] Refactor README.md to update property name from 'extras' to 'raw_all' --- README.md | 10 +++++----- src/Audio.php | 24 ++++++++++++------------ 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 0db74de..2838a35 100644 --- a/README.md +++ b/README.md @@ -235,9 +235,9 @@ $tag = $audio->write() ### Raw tags -Audio files format metadata with different methods, `JamesHeinrich/getID3` offer to check these metadatas by different methods. In `extras` property of `Audio::class`, you will find raw metadata from `JamesHeinrich/getID3` package, like `id3v2`, `id3v1`, `riff`, `asf`, `quicktime`, `matroska`, `ape`, `vorbiscomment`... +Audio files format metadata with different methods, `JamesHeinrich/getID3` offer to check these metadatas by different methods. In `raw_all` property of `Audio::class`, you will find raw metadata from `JamesHeinrich/getID3` package, like `id3v2`, `id3v1`, `riff`, `asf`, `quicktime`, `matroska`, `ape`, `vorbiscomment`... -If you want to extract specific field which can be skipped by `Audio::class`, you can use `extras` property. +If you want to extract specific field which can be skipped by `Audio::class`, you can use `raw_all` property. ```php use Kiwilan\Audio\Audio; @@ -446,7 +446,7 @@ composer test ### I have a specific metadata field in my audio files, what can I do? -In `Audio::class`, you have a property `extras` which contains all raw metadata, if `JamesHeinrich/getID3` support this field, you will find it in this property. +In `Audio::class`, you have a property `raw_all` which contains all raw metadata, if `JamesHeinrich/getID3` support this field, you will find it in this property. ```php use Kiwilan\Audio\Audio; @@ -473,8 +473,8 @@ use Kiwilan\Audio\Audio; $audio = Audio::read('path/to/audio.mp3'); -$extras = $audio->getRawAll(); -var_dump($extras); +$raw_all = $audio->getRawAll(); +var_dump($raw_all); ``` If you find metadata which are not parsed by `Audio::class`, you can create [an issue](https://github.com/kiwilan/php-audio/issues/new/choose), otherwise `JamesHeinrich/getID3` doesn't support this metadata.z diff --git a/src/Audio.php b/src/Audio.php index b3525fe..2047ae5 100755 --- a/src/Audio.php +++ b/src/Audio.php @@ -13,7 +13,7 @@ class Audio { /** - * @param array $raw_tags_all + * @param array $raw_all */ protected function __construct( protected string $path, @@ -47,7 +47,7 @@ protected function __construct( protected ?string $language = null, protected ?string $lyrics = null, - protected array $raw_tags_all = [], + protected array $raw_all = [], ) {} public static function read(string $path): self @@ -411,7 +411,7 @@ public function getLyrics(): ?string */ public function getRawAll(): array { - return $this->raw_tags_all; + return $this->raw_all; } /** @@ -425,16 +425,16 @@ public function getRawAll(): array public function getRaw(?string $format = null): ?array { if ($format) { - return $this->raw_tags_all[$format] ?? null; + return $this->raw_all[$format] ?? null; } $tags = match ($this->type) { - AudioTypeEnum::id3 => $this->raw_tags_all['id3v2'] ?? [], - AudioTypeEnum::vorbiscomment => $this->raw_tags_all['vorbiscomment'] ?? [], - AudioTypeEnum::quicktime => $this->raw_tags_all['quicktime'] ?? [], - AudioTypeEnum::matroska => $this->raw_tags_all['matroska'] ?? [], - AudioTypeEnum::ape => $this->raw_tags_all['ape'] ?? [], - AudioTypeEnum::asf => $this->raw_tags_all['asf'] ?? [], + AudioTypeEnum::id3 => $this->raw_all['id3v2'] ?? [], + AudioTypeEnum::vorbiscomment => $this->raw_all['vorbiscomment'] ?? [], + AudioTypeEnum::quicktime => $this->raw_all['quicktime'] ?? [], + AudioTypeEnum::matroska => $this->raw_all['matroska'] ?? [], + AudioTypeEnum::ape => $this->raw_all['ape'] ?? [], + AudioTypeEnum::asf => $this->raw_all['asf'] ?? [], default => [], }; @@ -485,7 +485,7 @@ public function toArray(): array 'synopsis' => $this->synopsis, 'language' => $this->language, 'lyrics' => $this->lyrics, - 'raw_tags_all' => $this->raw_tags_all, + 'raw_all' => $this->raw_all, ]; } @@ -522,7 +522,7 @@ private function parseTags(?\Kiwilan\Audio\Id3\Id3Reader $id3_reader): self $raw_tags = $id3_reader->getRaw()['tags'] ?? []; foreach ($raw_tags as $name => $raw_tag) { - $this->raw_tags_all[$name] = Id3Reader::cleanTags($raw_tag); + $this->raw_all[$name] = Id3Reader::cleanTags($raw_tag); } $core = match ($this->type) {