/**
  * Returns whether the given parameter values are valid.
  *
  * @param array $parameterValues          The parameter values to
  *                                        validate.
  * @param InstallerDescriptor $descriptor The installer descriptor to
  *                                        validate the values for.
  *
  * @return ConstraintViolation[] The found violations. If no violations were
  *                               found, an empty array is returned.
  */
 public function validate(array $parameterValues, InstallerDescriptor $descriptor)
 {
     $violations = array();
     foreach ($parameterValues as $name => $value) {
         if (!$descriptor->hasParameter($name)) {
             $violations[] = new ConstraintViolation(ConstraintViolation::NO_SUCH_PARAMETER, $value, $descriptor->getName(), $name);
         }
     }
     foreach ($descriptor->getParameters() as $parameter) {
         if (!isset($parameterValues[$parameter->getName()])) {
             if ($parameter->isRequired()) {
                 $violations[] = new ConstraintViolation(ConstraintViolation::MISSING_PARAMETER, $parameterValues, $descriptor->getName(), $parameter->getName());
             }
         }
     }
     return $violations;
 }
 private function loadInstaller(InstallerDescriptor $descriptor)
 {
     $installerName = $descriptor->getName();
     if (!isset($this->installers[$installerName])) {
         $installerClass = $descriptor->getClassName();
         $this->validateInstallerClass($installerClass);
         $this->installers[$installerName] = new $installerClass();
     }
     return $this->installers[$installerName];
 }
 public function testMatch()
 {
     $descriptor = new InstallerDescriptor('symlink', self::SYMLINK_CLASS, 'The description');
     $this->assertFalse($descriptor->match(Expr::same('copy', InstallerDescriptor::NAME)));
     $this->assertTrue($descriptor->match(Expr::same('symlink', InstallerDescriptor::NAME)));
     $this->assertFalse($descriptor->match(Expr::same('FooBar', InstallerDescriptor::CLASS_NAME)));
     $this->assertTrue($descriptor->match(Expr::same(self::SYMLINK_CLASS, InstallerDescriptor::CLASS_NAME)));
     $this->assertFalse($descriptor->match(Expr::same('Foo description', InstallerDescriptor::DESCRIPTION)));
     $this->assertTrue($descriptor->match(Expr::same('The description', InstallerDescriptor::DESCRIPTION)));
 }
 private function installerToData(InstallerDescriptor $installer)
 {
     $data = (object) array('class' => $installer->getClassName());
     if ($installer->getDescription()) {
         $data->description = $installer->getDescription();
     }
     if ($installer->getParameters()) {
         $data->parameters = $this->parametersToData($installer->getParameters());
     }
     return $data;
 }