Exemple #1
0
 /**
  * accepts the object in the form of an array structure
  * @param  [winged] $scale [description]
  * @return [winged]        [description]
  */
 public static function constructFromArray($props)
 {
     switch ($props['directionType']) {
         case 'metronome':
             return DirectionMetronome::constructFromArray($props);
             break;
         case 'dynamics':
             return DirectionDynamics::constructFromArray($props);
             break;
     }
 }
Exemple #2
0
 public static function constructFromArray($props)
 {
     $layers = array();
     if (isset($props['layers'])) {
         foreach ($props['layers'] as $layer) {
             if ($layer instanceof Layer) {
                 $layers[] = $layer;
             } else {
                 $layers[] = Layer::constructFromArray($layer);
             }
         }
     }
     $directions = array();
     if (isset($props['directions'])) {
         foreach ($props['directions'] as $direction) {
             switch ($direction['directionType']) {
                 case 'metronome':
                     $directions[] = DirectionMetronome::constructFromArray($direction);
                     break;
                 case 'dynamics':
                     $directions[] = DirectionDynamics::constructFromArray($direction);
                     break;
                 default:
             }
         }
     }
     if ($props['time'] instanceof Time) {
         $time = $props['time'];
     } else {
         $time = Time::constructFromArray($props['time']);
     }
     if ($props['clef'] instanceof Clef) {
         $clef = $props['clef'];
     } else {
         $clef = Clef::constructFromArray($props['clef']);
     }
     if ($props['key'] instanceof Key) {
         $key = $props['key'];
     } else {
         $key = Key::constructFromArray($props['key']);
     }
     $divisions = $props['divisions'];
     if ($props['barline'] instanceof Barline) {
         $barline = $props['barline'];
     } else {
         $barline = Barline::constructFromArray($props['barline']);
     }
     $implicit = $props['implicit'];
     $nonControlling = $props['nonControlling'];
     $width = $props['width'];
     return new Measure($layers, $directions, $time, $clef, $key, $divisions, $barline, $implicit, $nonControlling, $width);
 }