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.
		
		
		
		
		
			
		
			
				
					
					
						
							41 lines
						
					
					
						
							1.0 KiB
						
					
					
				
			
		
		
		
			
			
			
				
					
				
				
					
				
			
		
		
	
	
							41 lines
						
					
					
						
							1.0 KiB
						
					
					
				
								<?php
							 | 
						|
								
							 | 
						|
								namespace App\Dataclasses;
							 | 
						|
								
							 | 
						|
								class TuneVariant
							 | 
						|
								{
							 | 
						|
								    private DatabaseFolkTuneDetails $Tune;
							 | 
						|
								    public string $ID;
							 | 
						|
								    public array $Parts;
							 | 
						|
								
							 | 
						|
								    public function __construct(DatabaseFolkTuneDetails $tuneDetails, array $assocArray)
							 | 
						|
								    {
							 | 
						|
								        $this->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;
							 | 
						|
								    }
							 | 
						|
								}
							 | 
						|
								
							 |