You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
1.1 KiB
50 lines
1.1 KiB
<?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;
|
|
}
|
|
}
|