evaluate() 공개 메소드

Evaluates the expression with the given value.
public evaluate ( mixed $value ) : boolean
$value mixed A value.
리턴 boolean Returns `true` if the value satisfies the expression and `false` otherwise.
예제 #1
0
 protected function hasBindingsWithTypeNameThatMatch($typeName, Expression $expr)
 {
     if (!$this->hasBindingsWithTypeName($typeName)) {
         return false;
     }
     $key = $this->keysByTypeName[$typeName];
     if (!isset($this->bindingsByKey[$key])) {
         $this->loadBindingsForKey($key);
     }
     foreach ($this->bindingsByKey[$key] as $binding) {
         if ($expr->evaluate($binding)) {
             return true;
         }
     }
     return false;
 }
예제 #2
0
 /**
  * {@inheritdoc}
  */
 public function findExtraKeys(Expression $expr)
 {
     $values = array();
     foreach ($this->rootPackageFile->getExtraKeys() as $key => $value) {
         if ($expr->evaluate($key)) {
             $values[$key] = $value;
         }
     }
     return $values;
 }
예제 #3
0
 /**
  * Returns whether the server matches the given expression.
  *
  * @param Expression $expr The search criteria. You can use the fields
  *                         {@link NAME}, {@link INSTALLER_NAME},
  *                         {@link DOCUMENT_ROOT}, {@link URL_FORMAT} and
  *                         {@link PARAMETER_VALUES} in the expression.
  *
  * @return bool Returns `true` if the server matches the expression and
  *              `false` otherwise.
  */
 public function match(Expression $expr)
 {
     return $expr->evaluate(array(self::NAME => $this->name, self::INSTALLER_NAME => $this->installerName, self::DOCUMENT_ROOT => $this->documentRoot, self::URL_FORMAT => $this->urlFormat, self::PARAMETER_VALUES => $this->parameterValues));
 }
예제 #4
0
 /**
  * {@inheritdoc}
  */
 public function hasModules(Expression $expr = null)
 {
     $this->assertModulesLoaded();
     if (!$expr) {
         return !$this->modules->isEmpty();
     }
     foreach ($this->modules as $module) {
         if ($expr->evaluate($module)) {
             return true;
         }
     }
     return false;
 }
 /**
  * Returns whether the binding type matches the given expression.
  *
  * @param Expression $expr The search criteria. You can use the fields
  *                         {@link NAME}, {@link PARAMETERS},
  *                         {@link STATE} and {@link CONTAINING_PACKAGE}
  *                         in the expression.
  *
  * @return bool Returns `true` if the binding type matches the expression
  *              and `false` otherwise.
  */
 public function match(Expression $expr)
 {
     return $expr->evaluate(array(self::NAME => $this->name, self::STATE => $this->state, self::CONTAINING_PACKAGE => $this->containingPackage->getName()));
 }
예제 #6
0
 /**
  * {@inheritdoc}
  */
 protected function removeBindingsWithTypeNameThatMatch($typeName, Expression $expr)
 {
     if (!isset($this->bindingsByTypeName[$typeName])) {
         return;
     }
     foreach ($this->bindingsByTypeName[$typeName] as $uuidString => $binding) {
         if ($expr->evaluate($binding)) {
             unset($this->bindings[$uuidString]);
             unset($this->bindingsByTypeName[$typeName][$uuidString]);
         }
     }
 }
예제 #7
0
 /**
  * Returns whether the target matches the given expression.
  *
  * @param Expression $expr The search criteria. You can use the fields
  *                         {@link NAME}, {@link CLASS_NAME},
  *                         {@link LOCATION}, {@link URL_FORMAT} and
  *                         {@link PARAMETER_VALUES} in the expression.
  *
  * @return bool Returns `true` if the target matches the expression and
  *              `false` otherwise.
  */
 public function match(Expression $expr)
 {
     return $expr->evaluate(array(self::NAME => $this->name, self::INSTALLER_NAME => $this->installerName, self::LOCATION => $this->location, self::URL_FORMAT => $this->urlFormat, self::PARAMETER_VALUES => $this->parameterValues));
 }
예제 #8
0
 /**
  * {@inheritdoc}
  */
 public function hasBindingDescriptors(Expression $expr = null)
 {
     $this->assertModulesLoaded();
     if (!$expr) {
         return !$this->bindingDescriptors->isEmpty();
     }
     foreach ($this->bindingDescriptors->toArray() as $bindingDescriptor) {
         if ($expr->evaluate($bindingDescriptor)) {
             return true;
         }
     }
     return false;
 }
예제 #9
0
 /**
  * Returns whether the installer matches the given expression.
  *
  * @param Expression $expr The search criteria. You can use the fields
  *                         {@link NAME}, {@link CLASS_NAME} and
  *                         {@link DESCRIPTION} in the expression.
  *
  * @return bool Returns `true` if the installer matches the expression and
  *              `false` otherwise.
  */
 public function match(Expression $expr)
 {
     return $expr->evaluate(array(self::NAME => $this->name, self::CLASS_NAME => $this->className, self::DESCRIPTION => $this->description));
 }
예제 #10
0
 /**
  * Returns whether the path mapping matches the given expression.
  *
  * @param Expression $expr The search criteria. You can use the fields
  *                         {@link REPOSITORY_PATH}, {@link STATE} and
  *                         {@link CONTAINING_PACKAGE} in the expression.
  *
  * @return bool Returns `true` if the path mapping matches the expression
  *              and `false` otherwise.
  */
 public function match(Expression $expr)
 {
     return $expr->evaluate(array(self::REPOSITORY_PATH => $this->repositoryPath, self::STATE => $this->state, self::CONTAINING_PACKAGE => $this->containingPackage->getName()));
 }
예제 #11
0
파일: Package.php 프로젝트: kormik/manager
 /**
  * Returns whether the package matches the given expression.
  *
  * @param Expression $expr The search criteria. You can use the fields
  *                         {@link NAME}, {@link INSTALL_PATH} and
  *                         {@link STATE} in the expression.
  *
  * @return bool Returns `true` if the package matches the expression and
  *              `false` otherwise.
  */
 public function match(Expression $expr)
 {
     return $expr->evaluate(array(self::NAME => $this->name, self::INSTALL_PATH => $this->installPath, self::STATE => $this->state, self::INSTALLER => $this->installInfo ? $this->installInfo->getInstallerName() : null, self::ENVIRONMENT => $this->installInfo ? $this->installInfo->getEnvironment() : Environment::PROD));
 }
예제 #12
0
 /**
  * {@inheritdoc}
  */
 protected function hasBindingsWithTypeNameThatMatch($typeName, Expression $expr)
 {
     if (!isset($this->bindingsByTypeName[$typeName])) {
         return false;
     }
     foreach ($this->bindingsByTypeName[$typeName] as $binding) {
         if ($expr->evaluate($binding)) {
             return true;
         }
     }
     return false;
 }
예제 #13
0
 /**
  * {@inheritdoc}
  */
 public function hasServers(Expression $expr = null)
 {
     $this->assertServersLoaded();
     if (!$expr) {
         return !$this->servers->isEmpty();
     }
     foreach ($this->servers as $server) {
         if ($expr->evaluate($server)) {
             return true;
         }
     }
     return false;
 }
예제 #14
0
 /**
  * Returns whether the binding matches the given expression.
  *
  * @param Expression $expr The search criteria. You can use the fields
  *                         {@link UUID}, {@link QUERY}, {@link LANGUAGE},
  *                         {@link TYPE_NAME}, {@link STATE} and
  *                         {@link CONTAINING_PACKAGE} in the expression.
  *
  * @return bool Returns `true` if the binding matches the expression and
  *              `false` otherwise.
  */
 public function match(Expression $expr)
 {
     return $expr->evaluate(array(self::UUID => $this->uuid->toString(), self::QUERY => $this->query, self::LANGUAGE => $this->language, self::TYPE_NAME => $this->typeName, self::PARAMETER_VALUES => $this->parameterValues, self::STATE => $this->state, self::CONTAINING_PACKAGE => $this->containingPackage->getName()));
 }
예제 #15
0
 /**
  * {@inheritdoc}
  */
 public function findConfigKeys(Expression $expr, $includeFallback = false, $includeUnset = false, $raw = true)
 {
     Assert::boolean($includeFallback, 'The argument $includeFallback must be a boolean.');
     Assert::boolean($includeUnset, 'The argument $includeUnset must be a boolean.');
     $values = array();
     foreach ($this->getConfigKeys($includeFallback, $includeUnset, $raw) as $key => $value) {
         if ($expr->evaluate($key)) {
             $values[$key] = $value;
         }
     }
     return $values;
 }
예제 #16
0
 /**
  * Returns whether the package matches the given expression.
  *
  * @param Expression $expr The search criteria. You can use the fields
  *                         {@link NAME}, {@link INSTALL_PATH} and
  *                         {@link STATE} in the expression.
  *
  * @return bool Returns `true` if the package matches the expression and
  *              `false` otherwise.
  */
 public function match(Expression $expr)
 {
     return $expr->evaluate(array(self::NAME => $this->name, self::INSTALL_PATH => $this->installPath, self::STATE => $this->state, self::INSTALLER => $this->installInfo ? $this->installInfo->getInstallerName() : null));
 }
예제 #17
0
 /**
  * {@inheritdoc}
  */
 public function hasPathMappings(Expression $expr = null)
 {
     $this->assertMappingsLoaded();
     if (!$expr) {
         return !$this->mappings->isEmpty();
     }
     foreach ($this->mappings->toArray() as $mappingsByModule) {
         foreach ($mappingsByModule as $mapping) {
             if ($expr->evaluate($mapping)) {
                 return true;
             }
         }
     }
     return false;
 }
 /**
  * {@inheritdoc}
  */
 public function hasInstallerDescriptors(Expression $expr = null)
 {
     $this->assertInstallersLoaded();
     if (!$expr) {
         return count($this->installerDescriptors) > 0;
     }
     foreach ($this->installerDescriptors as $installer) {
         if ($expr->evaluate($installer)) {
             return true;
         }
     }
     return false;
 }
예제 #19
0
 /**
  * Filter a collection for entries matching the expression.
  *
  * @param array|ArrayAccess|Traversable $collection An array or an object
  *                                                  implementing Traversable
  *                                                  and ArrayAccess.
  * @param Expression                    $expr       The expression to
  *                                                  evaluate for each entry.
  *
  * @return array|ArrayAccess|Traversable The filtered collection.
  */
 public static function filter($collection, Expression $expr)
 {
     if (is_array($collection)) {
         return array_filter($collection, array($expr, 'evaluate'));
     }
     if (!($collection instanceof Traversable && $collection instanceof ArrayAccess)) {
         throw new InvalidArgumentException(sprintf('Expected an array or an instance of Traversable and ArrayAccess. Got: %s', is_object($collection) ? get_class($collection) : gettype($collection)));
     }
     $clone = clone $collection;
     foreach ($collection as $key => $value) {
         if (!$expr->evaluate($value)) {
             unset($clone[$key]);
         }
     }
     return $clone;
 }