parseVersion() public méthode

Parses and returns the version of a JSON object.
public parseVersion ( stdClass $jsonData ) : string
$jsonData stdClass The JSON object
Résultat string The version
Exemple #1
0
 /**
  * Migrates a JSON object to the given version.
  *
  * @param stdClass $data          The JSON object
  * @param string   $targetVersion The version string
  */
 public function migrate(stdClass $data, $targetVersion)
 {
     $sourceVersion = $this->versioner->parseVersion($data);
     if (version_compare($targetVersion, $sourceVersion, '>')) {
         $this->up($data, $sourceVersion, $targetVersion);
     } elseif (version_compare($targetVersion, $sourceVersion, '<')) {
         $this->down($data, $sourceVersion, $targetVersion);
     }
 }
Exemple #2
0
 /**
  * {@inheritdoc}
  */
 public function fromJson($jsonData, array $options = array())
 {
     Assert::isInstanceOf($jsonData, 'stdClass');
     $moduleFile = new ModuleFile(null, isset($options['path']) ? $options['path'] : null);
     $moduleFile->setVersion($this->versioner->parseVersion($jsonData));
     $this->addJsonToModuleFile($jsonData, $moduleFile);
     return $moduleFile;
 }