/** * {@inheritdoc} */ public function isAllowed(NodeInterface $from, NodeInterface $to) { foreach ($this->getTargets() as $namespace) { if ($this->namespaceContains($namespace, $to->getFQName())) { return EvaluationResult::allowed($this); } } return EvaluationResult::undefined(); }
/** * {@inheritdoc} */ public function isAllowed(NodeInterface $from, NodeInterface $to) { foreach ($this->getTargets() as $namespace) { if ($this->namespaceContains($namespace, $to->getFQName())) { return EvaluationResult::denied($this, sprintf("%s has an attached DenyPolicy of namespace %s, preventing use of %s", $from->getFQName(), $namespace, $to->getFQName())); } } return EvaluationResult::undefined(); }
/** * {@inheritdoc} */ public function affects(NodeInterface $from, NodeInterface $to) { foreach ($this->getTargets() as $namespace) { if ($this->namespaceContains($namespace, $to->getFQName())) { return true; } } return false; }
private function parentNamespace(NodeInterface $node) { $fqcn = $node->getFQName(); $lastNsSep = strpos($fqcn, '\\'); if (false === $lastNsSep) { // no namespace return ""; } else { return substr($fqcn, 0, $lastNsSep); } }
private function regexMatchesNode($regex, NodeInterface $node) { return (bool) preg_match("/{$regex}/i", $node->getFQName()); }
/** * Adds a child to the current node. * * @param NodeInterface $child */ public function addChild(NodeInterface $child) { $this->children[$child->getName()] = $child; }