Skip to content

Commit

Permalink
Merge pull request #22 from miqwit/add-simple-functions
Browse files Browse the repository at this point in the history
add grid and icpn getters at album level; expose display artists, art…
  • Loading branch information
miqwit authored Jan 31, 2023
2 parents 9d97649 + 267600f commit 30ad0c0
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 5 deletions.
47 changes: 46 additions & 1 deletion src/Simplifiers/SimpleAlbum.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public function __construct($ern) {
// Find release of type MainRelease from this ERN
foreach ($this->ern->getReleaseList()->getRelease() as $release) {
foreach ($release->getReleaseType() as $type) {
if (in_array(strtolower($type->value()), ["album", "classicalalbum"])) {
if (in_array(strtolower($type->value()), ["album", "classicalalbum", "single"])) {
$this->ddexReleaseAlbum = $release;
} else {
$this->trackReleasesByReference[$release->getReleaseReference()[0]] = $release;
Expand Down Expand Up @@ -523,5 +523,50 @@ public function getCLineText(): ?string {
return null;
}
}

/**
* Assumption: there is only one ReleaseId
*
* @return string|null
*/
public function getGrid(): ?string {
try {
return $this->ddexReleaseAlbum->getReleaseId()[0]->getGRid();
} catch (Throwable $ex) {
return null;
} catch (Exception $ex) {
return null;
}
}

/**
* Assumption: there is only one ReleaseId
*
* @return string|null
*/
public function getIcpn(): ?string {
try {
return $this->ddexReleaseAlbum->getReleaseId()[0]->getICPN();
} catch (Throwable $ex) {
return null;
} catch (Exception $ex) {
return null;
}
}

/**
* Assumption: there is only one ReleaseId
*
* @return string|null
*/
public function getCatalogNumber(): ?string {
try {
return $this->ddexReleaseAlbum->getReleaseId()[0]->getCatalogNumber();
} catch (Throwable $ex) {
return null;
} catch (Exception $ex) {
return null;
}
}

}
8 changes: 4 additions & 4 deletions src/Simplifiers/SimpleTrack.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ public function getDurationInSeconds(): ?int {
*
* @return SimpleArtist[]
*/
private function getDisplayArtists() {
public function getDisplayArtists() {
$artists = [];

foreach ($this->ddexDetails->getDisplayArtist() as $artist) {
Expand All @@ -263,7 +263,7 @@ private function getDisplayArtists() {
*
* @return SimpleArtist
*/
private function getArtistsFromResourceContributors() {
public function getArtistsFromResourceContributors() {
$artists = [];

foreach ($this->ddexDetails->getResourceContributor() as $artist) {
Expand All @@ -284,7 +284,7 @@ private function getArtistsFromResourceContributors() {
*
* @return SimpleArtist
*/
private function getArtistsFromIndirectResourceContributors() {
public function getArtistsFromIndirectResourceContributors() {
$artists = [];

foreach ($this->ddexDetails->getIndirectResourceContributor() as $artist) {
Expand All @@ -307,7 +307,7 @@ private function getArtistsFromIndirectResourceContributors() {
*
* Ignores sequence numbering. Keep the order as written in the XML.
*
* @return SimpleArtist
* @return SimpleArtist[]
*/
public function getArtists() {
// Display artists
Expand Down

0 comments on commit 30ad0c0

Please sign in to comment.