Ejemplo n.º 1
0
 /**
  * {@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();
 }
Ejemplo n.º 2
0
 /**
  * {@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();
 }
Ejemplo n.º 3
0
 /**
  * {@inheritdoc}
  */
 public function affects(NodeInterface $from, NodeInterface $to)
 {
     foreach ($this->getTargets() as $namespace) {
         if ($this->namespaceContains($namespace, $to->getFQName())) {
             return true;
         }
     }
     return false;
 }
Ejemplo n.º 4
0
 private function parentNamespace(NodeInterface $node)
 {
     $fqcn = $node->getFQName();
     $lastNsSep = strpos($fqcn, '\\');
     if (false === $lastNsSep) {
         // no namespace
         return "";
     } else {
         return substr($fqcn, 0, $lastNsSep);
     }
 }
Ejemplo n.º 5
0
 private function regexMatchesNode($regex, NodeInterface $node)
 {
     return (bool) preg_match("/{$regex}/i", $node->getFQName());
 }
Ejemplo n.º 6
0
 /**
  * Adds a child to the current node.
  *
  * @param NodeInterface $child
  */
 public function addChild(NodeInterface $child)
 {
     $this->children[$child->getName()] = $child;
 }