From 83fb1a71f40f1a9baf24d61ef72793fbed6b5203 Mon Sep 17 00:00:00 2001 From: Thorsten Bus Date: Sun, 1 Mar 2026 16:34:00 +0100 Subject: [PATCH] [AI] add Song metadata getters/setters for CCLI, category, notes Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus --- php/src/Song.php | 125 +++++++++++++++++++++++++++++++++ php/tests/SongMetadataTest.php | 79 +++++++++++++++++++++ 2 files changed, 204 insertions(+) create mode 100644 php/tests/SongMetadataTest.php diff --git a/php/src/Song.php b/php/src/Song.php index bed1fb6..232bdaf 100644 --- a/php/src/Song.php +++ b/php/src/Song.php @@ -5,6 +5,8 @@ declare(strict_types=1); namespace ProPresenter\Parser; use Rv\Data\Presentation; +use Rv\Data\Presentation\CCLI; +use Rv\Data\UUID; class Song { @@ -63,6 +65,118 @@ class Song $this->presentation->setName($name); } + public function getCcliAuthor(): string + { + return $this->presentation->getCcli()?->getAuthor() ?? ''; + } + + public function setCcliAuthor(string $author): void + { + $this->ensureCcli()->setAuthor($author); + } + + public function getCcliSongTitle(): string + { + return $this->presentation->getCcli()?->getSongTitle() ?? ''; + } + + public function setCcliSongTitle(string $title): void + { + $this->ensureCcli()->setSongTitle($title); + } + + public function getCcliPublisher(): string + { + return $this->presentation->getCcli()?->getPublisher() ?? ''; + } + + public function setCcliPublisher(string $publisher): void + { + $this->ensureCcli()->setPublisher($publisher); + } + + public function getCcliCopyrightYear(): int + { + return $this->presentation->getCcli()?->getCopyrightYear() ?? 0; + } + + public function setCcliCopyrightYear(int $year): void + { + $this->ensureCcli()->setCopyrightYear($year); + } + + public function getCcliSongNumber(): int + { + return $this->presentation->getCcli()?->getSongNumber() ?? 0; + } + + public function setCcliSongNumber(int $number): void + { + $this->ensureCcli()->setSongNumber($number); + } + + public function getCcliDisplay(): bool + { + return $this->presentation->getCcli()?->getDisplay() ?? false; + } + + public function setCcliDisplay(bool $display): void + { + $this->ensureCcli()->setDisplay($display); + } + + public function getCcliArtistCredits(): string + { + return $this->presentation->getCcli()?->getArtistCredits() ?? ''; + } + + public function setCcliArtistCredits(string $credits): void + { + $this->ensureCcli()->setArtistCredits($credits); + } + + public function getCcliAlbum(): string + { + return $this->presentation->getCcli()?->getAlbum() ?? ''; + } + + public function setCcliAlbum(string $album): void + { + $this->ensureCcli()->setAlbum($album); + } + + public function getCategory(): string + { + return $this->presentation->getCategory(); + } + + public function setCategory(string $category): void + { + $this->presentation->setCategory($category); + } + + public function getNotes(): string + { + return $this->presentation->getNotes(); + } + + public function setNotes(string $notes): void + { + $this->presentation->setNotes($notes); + } + + public function getSelectedArrangementUuid(): string + { + return $this->presentation->getSelectedArrangement()?->getString() ?? ''; + } + + public function setSelectedArrangementUuid(string $uuid): void + { + $arrangementUuid = new UUID(); + $arrangementUuid->setString($uuid); + $this->presentation->setSelectedArrangement($arrangementUuid); + } + public function getGroups(): array { return $this->groups; @@ -125,4 +239,15 @@ class Song { return $this->presentation; } + + private function ensureCcli(): CCLI + { + $ccli = $this->presentation->getCcli(); + if ($ccli === null) { + $ccli = new CCLI(); + $this->presentation->setCcli($ccli); + } + + return $ccli; + } } diff --git a/php/tests/SongMetadataTest.php b/php/tests/SongMetadataTest.php new file mode 100644 index 0000000..e2b7c5a --- /dev/null +++ b/php/tests/SongMetadataTest.php @@ -0,0 +1,79 @@ +setCcliAuthor('Author Name'); + + $this->assertSame('Author Name', $song->getCcliAuthor()); + } + + #[Test] + public function ccliSongNumberRoundTripWorks(): void + { + $song = new Song(new Presentation()); + + $song->setCcliSongNumber(123456); + + $this->assertSame(123456, $song->getCcliSongNumber()); + } + + #[Test] + public function categoryRoundTripWorks(): void + { + $song = new Song(new Presentation()); + + $song->setCategory('Worship'); + + $this->assertSame('Worship', $song->getCategory()); + } + + #[Test] + public function notesRoundTripWorks(): void + { + $song = new Song(new Presentation()); + + $song->setNotes('Use acoustic intro'); + + $this->assertSame('Use acoustic intro', $song->getNotes()); + } + + #[Test] + public function selectedArrangementUuidRoundTripWorks(): void + { + $song = new Song(new Presentation()); + $uuid = '12345678-1234-4234-8234-123456789abc'; + + $song->setSelectedArrangementUuid($uuid); + + $this->assertSame($uuid, $song->getSelectedArrangementUuid()); + } + + #[Test] + public function ccliGettersReturnDefaultsWithoutCcliData(): void + { + $song = new Song(new Presentation()); + + $this->assertSame('', $song->getCcliAuthor()); + $this->assertSame('', $song->getCcliSongTitle()); + $this->assertSame('', $song->getCcliPublisher()); + $this->assertSame(0, $song->getCcliCopyrightYear()); + $this->assertSame(0, $song->getCcliSongNumber()); + $this->assertFalse($song->getCcliDisplay()); + $this->assertSame('', $song->getCcliArtistCredits()); + $this->assertSame('', $song->getCcliAlbum()); + } +}