Skip to content

Commit e272729

Browse files
v3.0.01
- Add `getContents()` to AudioCover - Old method `getContent()` is deprecated
1 parent e6528ea commit e272729

File tree

7 files changed

+19
-21
lines changed

7 files changed

+19
-21
lines changed

README.md

+1-12
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,6 @@ Audio files can use different formats, this package aims to provide a simple way
3030

3131
- Add support for more formats with [external packages](https://askubuntu.com/questions/226773/how-to-read-mp3-tags-in-shell)
3232

33-
| Program | Version | Time / s |
34-
| :------: | :--------: | :--------: |
35-
| exiftool | 10.25 | 49.5 ± 0.5 |
36-
| lltag | 0.14.5 | 41 ± 1.0 |
37-
| ffprobe | 3.1.3-1+b3 | 33 ± 0.5 |
38-
| eyeD3 | 0.6.18 | 24 ± 0.5 |
39-
| id3info | 3.8.3 | 4.2 ± 0.1 |
40-
| id3v2 | 0.1.12 | 2.9 ± 0.1 |
41-
| id3tool | 1.2a | 1.7 ± 0.1 |
42-
| mp3info | 0.8.5a | 1.4 ± 0.1 |
43-
4433
## Installation
4534

4635
You can install the package via composer:
@@ -324,7 +313,7 @@ use Kiwilan\Audio\Audio;
324313

325314
$audio = Audio::get('path/to/audio.mp3');
326315

327-
$audio->getCover()->getContent(); // `?string` raw file
316+
$audio->getCover()->getContents(); // `?string` raw file
328317
$audio->getCover()->getMimeType(); // `?string` (image/jpeg, image/png, ...)
329318
$audio->getCover()->getWidth(); // `?int` in pixels
330319
$audio->getCover()->getHeight(); // `?int` in pixels

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "kiwilan/php-audio",
33
"description": "PHP package to parse and update audio files metadata, with `JamesHeinrich/getID3`.",
4-
"version": "3.0.0",
4+
"version": "3.0.01",
55
"keywords": [
66
"audio",
77
"php",

src/Audio.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ private function parse(): self
427427
$this->audio = AudioMetadata::make($this);
428428
$this->cover = AudioCover::make($reader->getComments());
429429

430-
if ($this->cover?->getContent()) {
430+
if ($this->cover?->getContents()) {
431431
$this->hasCover = true;
432432
}
433433

src/Models/AudioCover.php

+11-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
class AudioCover
66
{
7-
protected ?string $content = null;
7+
protected ?string $contents = null;
88

99
protected ?string $mimeType = null;
1010

@@ -20,17 +20,25 @@ public static function make(?Id3Comments $comments): ?self
2020

2121
$self = new self();
2222

23-
$self->content = $comments->picture()->data();
23+
$self->contents = $comments->picture()->data();
2424
$self->mimeType = $comments->picture()->image_mime();
2525
$self->width = $comments->picture()->image_width();
2626
$self->height = $comments->picture()->image_height();
2727

2828
return $self;
2929
}
3030

31+
/**
32+
* @deprecated Use `getContents()` instead.
33+
*/
3134
public function getContent(): ?string
3235
{
33-
return $this->content;
36+
return $this->contents;
37+
}
38+
39+
public function getContents(): ?string
40+
{
41+
return $this->contents;
3442
}
3543

3644
public function getMimeType(): ?string

tests/AudioTest.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
if ($audio->hasCover()) {
7272
expect($cover)->toBeInstanceOf(AudioCover::class);
7373
expect($cover->getContent())->toBeString();
74+
expect($cover->getContents())->toBeString();
7475
expect($cover->getMimeType())->toBeString();
7576
if ($cover->getWidth()) {
7677
expect($cover->getWidth())->toBeInt();
@@ -80,7 +81,7 @@
8081
}
8182

8283
$path = "tests/output/cover-{$ext}.jpg";
83-
file_put_contents($path, $cover->getContent());
84+
file_put_contents($path, $cover->getContents());
8485
expect(file_exists($path))->toBeTrue();
8586
expect($path)->toBeReadableFile();
8687
} else {

tests/Mp3Test.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@
4545
$cover = $audio->getCover();
4646

4747
expect($cover)->toBeInstanceOf(AudioCover::class);
48-
expect($cover->getContent())->toBeString();
48+
expect($cover->getContents())->toBeString();
4949
expect($cover->getMimeType())->toBe('image/jpeg');
5050
expect($cover->getWidth())->toBe(640);
5151
expect($cover->getHeight())->toBe(640);
5252

5353
$path = 'tests/output/cover.jpg';
54-
file_put_contents($path, $cover->getContent());
54+
file_put_contents($path, $cover->getContents());
5555
expect(file_exists($path))->toBeTrue();
5656
expect($path)->toBeReadableFile();
5757
});

tests/WriterTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@
106106
expect($audio->getTitle())->toBe($random);
107107

108108
$content = file_get_contents(FOLDER);
109-
expect($audio->getCover()->getContent())->toBe($content);
109+
expect($audio->getCover()->getContents())->toBe($content);
110110
})->with([MP3_WRITER]);
111111

112112
it('can update use tags with tag formats', function (string $path) {

0 commit comments

Comments
 (0)