/**
  * {@inheritdoc}
  */
 public function isValidBetween(Name $from, Name $to)
 {
     $this->lastResult = $this->inspector->isAllowed($from->toString(), $to->toString());
     if (!is_null($this->collector) && $this->lastResult->isDenied()) {
         $this->collector->major(new PolicyViolation($from, $to, $this->lastResult));
     }
     if (!is_null($this->collector) && $this->lastResult->isUndefined()) {
         $this->collector->undefined(new PolicyViolation($from, $to, $this->lastResult));
     }
     return $this->lastResult->isAllowed();
 }
Example #2
0
 /**
  * Analyses the architecture.
  *
  * @return bool true if the architecture raised no violation, false if there were violations
  */
 public function analyze(ReportWriterInterface $writer)
 {
     $phpDAConfig = $this->createPhpDAConfig();
     $usageFactory = new UsageFactory();
     $usage = $usageFactory->create();
     $usage->setOptions(['config' => $phpDAConfig]);
     // collect violation report
     $report = new PolicyViolationReport($this->config->getReportUndefined());
     $inspector = new Inspector();
     $inspector->load($this->config->getArchitecture());
     ReferenceValidator::getInstance()->setInspector($inspector);
     ReferenceValidator::getInstance()->setViolationCollector($report);
     $result = $usage->execute();
     // write report
     $writer->write($report);
     return $result;
 }