1 changed files with 50 additions and 0 deletions
@ -0,0 +1,50 @@ |
|||
<?php |
|||
|
|||
namespace App\Dataclasses; |
|||
|
|||
class ABCWrapper |
|||
{ |
|||
public string $ID; |
|||
public string $Title; |
|||
|
|||
public string $Source; |
|||
|
|||
public string $TimeSignature; |
|||
public string $KeySignature; |
|||
|
|||
public string $DefaultNoteLength = "1/8"; |
|||
|
|||
public array $Parts; |
|||
|
|||
|
|||
public function __construct(array $assocArray) |
|||
{ |
|||
$this->ID = $assocArray['ID']; |
|||
$this->Title = $assocArray['Title']; |
|||
$this->Source = $assocArray['Copyright']; |
|||
$this->TimeSignature = $assocArray['TimeSignature']; |
|||
$this->KeySignature = $assocArray['KeySignature']; |
|||
$this->Parts = json_decode($assocArray['Parts'], true); |
|||
} |
|||
|
|||
|
|||
public function Build(): string |
|||
{ |
|||
$builder = "X: {$this->ID} |
|||
T: {$this->Title} |
|||
S: {$this->Source} |
|||
M: {$this->TimeSignature} |
|||
K: {$this->KeySignature} |
|||
L: {$this->DefaultNoteLength}"; |
|||
$counter = 0; |
|||
$letters = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J']; |
|||
foreach($this->Parts as $part) |
|||
{ |
|||
$builder .= " |
|||
P: {$letters[$counter]} Part |
|||
{$part}"; |
|||
$counter = $counter + 1; |
|||
} |
|||
return $builder; |
|||
} |
|||
} |
Loading…
Reference in new issue