Example #1
0
 /**
  * Returns the package meta data object of this package.
  *
  * @return MetaData
  */
 public function getPackageMetaData()
 {
     if ($this->packageMetaData === NULL) {
         $this->packageMetaData = new MetaData($this->getPackageKey());
         $this->packageMetaData->setDescription($this->getValueFromComposerManifest('description'));
         $this->packageMetaData->setVersion($this->getValueFromComposerManifest('version'));
         $requirements = $this->getValueFromComposerManifest('require');
         if ($requirements !== NULL) {
             foreach ($requirements as $requirement => $version) {
                 if ($this->packageRequirementIsComposerPackage($requirement) === FALSE) {
                     // Skip non-package requirements
                     continue;
                 }
                 $packageKey = $this->packageManager->getPackageKeyFromComposerName($requirement);
                 $constraint = new MetaData\PackageConstraint(MetaData::CONSTRAINT_TYPE_DEPENDS, $packageKey);
                 $this->packageMetaData->addConstraint($constraint);
             }
         }
         $suggestions = $this->getValueFromComposerManifest('suggest');
         if ($suggestions !== NULL) {
             foreach ($suggestions as $suggestion => $version) {
                 if ($this->packageRequirementIsComposerPackage($suggestion) === FALSE) {
                     // Skip non-package requirements
                     continue;
                 }
                 $packageKey = $this->packageManager->getPackageKeyFromComposerName($suggestion);
                 $constraint = new MetaData\PackageConstraint(MetaData::CONSTRAINT_TYPE_SUGGESTS, $packageKey);
                 $this->packageMetaData->addConstraint($constraint);
             }
         }
     }
     return $this->packageMetaData;
 }