Skip to content

Commit 19d5184

Browse files
Merge pull request #14 from kiwilan/develop
v3.0.01
2 parents 7e9c67e + e272729 commit 19d5184

File tree

8 files changed

+28
-27
lines changed

8 files changed

+28
-27
lines changed

.github/workflows/run-tests.yml

+5-3
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,13 @@ jobs:
2424
php-version: ${{ matrix.php }}
2525
coverage: none
2626

27-
- name: apt
27+
- name: Linux installation
2828
if: runner.os == 'Linux'
29-
run: sudo apt-get install vorbis-tools flac
29+
run: |
30+
sudo apt update
31+
sudo apt install vorbis-tools flac
3032
31-
- name: scoop
33+
- name: Windows installation
3234
if: runner.os == 'Windows'
3335
run: |
3436
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

README.md

+5-15
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,6 @@ PHP package to parse and update audio files metadata, with [`JamesHeinrich/getID
1515
>
1616
> You can check formats supported on [Supported formats](#supported-formats) section.
1717
18-
## Table of contents
19-
20-
- [About](#about)
21-
- [Requirements](#requirements)
22-
- [Installation](#installation)
23-
- [Usage](#usage)
24-
- [Supported formats](#supported-formats)
25-
- [Testing](#testing)
26-
- [Tools](#tools)
27-
- [FAQ](#faq)
28-
- [Changelog](#changelog)
29-
- [Credits](#credits)
30-
- [License](#license)
31-
3218
## About
3319

3420
Audio files can use different formats, this package aims to provide a simple way to read them with [`JamesHeinrich/getID3`](https://github.com/JamesHeinrich/getID3). The `JamesHeinrich/getID3` package is excellent to read metadata from audio files, but output is just an array, current package aims to provide a simple way to read audio files with a beautiful API.
@@ -40,6 +26,10 @@ Audio files can use different formats, this package aims to provide a simple way
4026
- `FLAC`: `flac` (with `apt`, `brew` or `scoop`)
4127
- `OGG`: `vorbis-tools` (with `apt` or `brew`) / `extras/icecast` (with `scoop`)
4228

29+
### Roadmap
30+
31+
- Add support for more formats with [external packages](https://askubuntu.com/questions/226773/how-to-read-mp3-tags-in-shell)
32+
4333
## Installation
4434

4535
You can install the package via composer:
@@ -323,7 +313,7 @@ use Kiwilan\Audio\Audio;
323313

324314
$audio = Audio::get('path/to/audio.mp3');
325315

326-
$audio->getCover()->getContent(); // `?string` raw file
316+
$audio->getCover()->getContents(); // `?string` raw file
327317
$audio->getCover()->getMimeType(); // `?string` (image/jpeg, image/png, ...)
328318
$audio->getCover()->getWidth(); // `?int` in pixels
329319
$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)