Skip to content

Commit

Permalink
Refactor README.md to update property name from 'extras' to 'raw_all'
Browse files Browse the repository at this point in the history
  • Loading branch information
ewilan-riviere committed Oct 3, 2024
1 parent 8704a3b commit 2c83129
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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
Expand Down
24 changes: 12 additions & 12 deletions src/Audio.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
class Audio
{
/**
* @param array<string, string[]> $raw_tags_all
* @param array<string, string[]> $raw_all
*/
protected function __construct(
protected string $path,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -411,7 +411,7 @@ public function getLyrics(): ?string
*/
public function getRawAll(): array
{
return $this->raw_tags_all;
return $this->raw_all;
}

/**
Expand 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 => [],
};

Expand Down Expand Up @@ -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,
];
}

Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 2c83129

Please sign in to comment.