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; }
/** * {@inheritdoc} */ public function findExtraKeys(Expression $expr) { $values = array(); foreach ($this->rootPackageFile->getExtraKeys() as $key => $value) { if ($expr->evaluate($key)) { $values[$key] = $value; } } return $values; }
/** * 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)); }
/** * {@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())); }
/** * {@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]); } } }
/** * 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)); }
/** * {@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; }
/** * 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)); }
/** * 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())); }
/** * 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)); }
/** * {@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; }
/** * {@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; }
/** * 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())); }
/** * {@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; }
/** * 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)); }
/** * {@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; }
/** * 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; }