ID = $assocArray['ID']; $this->Tune = $tuneDetails; $temp = json_decode($assocArray['Parts'], associative: true, flags: JSON_THROW_ON_ERROR); foreach($temp as $part) $this->Parts[] = new TuneVariantPart($part); } public function Build(): string { $builder = "X: {$this->Tune->ID}.{$this->ID} T: {$this->Tune->Title} S: {$this->Tune->Copyright} M: {$this->Parts[0]->TimeSignature} K: {$this->Parts[0]->KeySignature} L: 1/8"; $counter = 0; $letters = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J']; foreach($this->Parts as $part) { $builder .= " P: {$letters[$counter]} Part {$part->ABCNotation}"; $counter = $counter + 1; } return $builder; } }