uiharu/src/AudioTags.php

67 lines
1.5 KiB
PHP

<?php
namespace Uiharu;
class AudioTags {
public function __construct(
private string $title = '',
private string $artist = '',
private string $album = '',
private string $date = '',
private string $comment = '',
private string $genre = ''
) {}
public function hasTitle(): bool {
return $this->title !== '';
}
public function getTitle(): string {
return $this->title;
}
public function hasArtist(): bool {
return $this->artist !== '';
}
public function getArtist(): string {
return $this->artist;
}
public function hasAlbum(): bool {
return $this->album !== '';
}
public function getAlbum(): string {
return $this->album;
}
public function hasDate(): bool {
return $this->date !== '';
}
public function getDate(): string {
return $this->date;
}
public function hasComment(): bool {
return $this->comment !== '';
}
public function getComment(): string {
return $this->comment;
}
public function hasGenre(): bool {
return $this->genre !== '';
}
public function getGenre(): string {
return $this->genre;
}
public static function fromMediaInfo(object $obj): AudioTags {
return new AudioTags(
$obj->tagTitle ?? '',
$obj->tagArtist ?? '',
$obj->tagAlbum ?? '',
$obj->tagDate ?? '',
$obj->tagComment ?? '',
$obj->tagGenre ?? '',
);
}
}