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; } }