/** * @param File $file input file to read */ public function __construct(File $file) { parent::__construct($file); $this->readVersion(); if (!$this->isSupportedVersion($this->getVersion())) { $this->closeStream(); throw new Exception(sprintf('Version "%s" is not supported', $this->getVersion())); } $song = new Song(); $this->setTablature($song); $this->factory('GuitarPro3Informations')->readInformations($song); $this->tripletFeel = $this->readBoolean() ? MeasureHeader::TRIPLET_FEEL_EIGHTH : MeasureHeader::TRIPLET_FEEL_NONE; $tempoValue = $this->readInt(); $this->keySignature = $this->factory('GuitarProKeySignature')->readKeySignature(); $this->skip(3); # Meta only if (Config::get('type') == 'meta') { $this->closeStream(); return; } $channels = $this->factory('GuitarProChannels')->readChannels(); $measures = $this->readInt(); $tracks = $this->readInt(); $this->readMeasureHeaders($song, $measures); $this->readTracks($song, $tracks, $channels); # Meta+channels+tracks+measure headers only if (Config::get('type') == 'channels') { $this->closeStream(); return; } $this->factory('GuitarPro3Measures')->readMeasures($song, $measures, $tracks, $tempoValue); $this->closeStream(); }
public function testConfig() { Config::clear(); # bad key format scenario $this->assertEquals(null, Config::get(array(42))); Config::set(array(42), 42); $this->assertEquals(null, Config::get(array(42))); # sets a good key Config::set('Sense', 42); $this->assertEquals(42, Config::get('Sense')); # Gets all configs $expected = array('Sense' => 42); $this->assertEquals($expected, Config::getAll()); }
/** * @param string $pathname A complete pathname */ public function __construct($pathname = null) { try { if (null === $pathname) { $this->setTablature(new Tablature()); } else { $reader = new Reader(new File($pathname)); $this->setTablature($reader->getTablature()); } } catch (Exception $e) { $message = sprintf('%s in %s on line %d%s', $e->getMessage(), $e->getFile(), $e->getLine(), PHP_EOL . $e->getTraceAsString() . PHP_EOL); # if debug mode, an error kills the process if (Config::get('debug')) { trigger_error($message, E_USER_ERROR); return; } $this->setTablature(new Tablature()); $this->getTablature()->setError($e->getMessage()); } }
/** * @param File $file input file to read */ public function __construct(File $file) { parent::__construct($file); $this->readVersion(); if (!$this->isSupportedVersion($this->getVersion())) { $this->closeStream(); throw new Exception(sprintf('Version "%s" is not supported', $this->getVersion())); } $song = new Song(); $this->setTablature($song); $this->factory('GuitarPro5Informations')->readInformations($song); # Meta only if (Config::get('type') == 'meta') { $this->closeStream(); return; } $lyricTrack = $this->readInt(); $lyric = $this->factory('GuitarProLyric')->readLyrics(); $this->readSetup(); $tempoValue = $this->readInt(); if ($this->getVersionIndex() > 0) { $this->skip(1); } $this->keySignature = $this->factory('GuitarProKeySignature')->readKeySignature(); $this->skip(3); $this->readByte(); $channels = $this->factory('GuitarProChannels')->readChannels(); $this->skip(42); $measures = $this->readInt(); $tracks = $this->readInt(); $this->readMeasureHeaders($song, $measures); $this->readTracks($song, $tracks, $channels, $lyric, $lyricTrack); $this->skip($this->getVersionIndex() == 0 ? 2 : 1); # Meta+channels+tracks+measure headers only if (Config::get('type') == 'channels') { $this->closeStream(); return; } $this->factory('GuitarPro5Measures')->readMeasures($song, $measures, $tracks, $tempoValue); $this->closeStream(); }