コード例 #1
0
 /** 
  * Scans (recursively) the path and runs the analyser for each file
  * @param ContextInterface $parent 
  */
 public function iterate(ContextInterface $parent)
 {
     $path = $parent->getName();
     foreach (new \DirectoryIterator($path) as $fileInfo) {
         if ($fileInfo->isDot()) {
             continue;
         }
         $fullPath = $path . DIRECTORY_SEPARATOR . $fileInfo->getFilename();
         if ($fileInfo->isDir() && !$this->isDirExcluded($fileInfo->getFilename())) {
             $dir = new DirectoryContext($fullPath);
             $this->iterate($dir);
             // no need to keep directories
             // with no mathing files
             if ($dir->hasChildren()) {
                 $parent->addChild($dir);
             }
         } elseif ($this->hasPhpExtension($fileInfo->getFilename())) {
             $file = new FileContext($fullPath);
             if ($this->verbose) {
                 echo $path . DIRECTORY_SEPARATOR . $fileInfo->getFilename() . "... ";
             }
             $this->analyser->scan($file);
             if ($this->verbose) {
                 echo "OK\n";
             } else {
                 echo ".";
             }
             $parent->addChild($file);
             $this->processedFilesCount++;
         }
     }
 }
コード例 #2
0
 /**
  * Return a count of total/testable procedures
  * @param ContextInterface $root
  * @return ['total' => 12, 'testable' => 4]
  */
 public function getTotalTestableProcedures(ContextInterface $root)
 {
     $total = 0;
     $testable = 0;
     foreach ($root->getChildrenRecursively(new ProcedureSpecification()) as $proc) {
         $total++;
         if (!$proc->hasIssues()) {
             $testable++;
         }
     }
     return ['total' => $total, 'testable' => $testable];
 }