Example #1
0
 public function testDetectModules()
 {
     $array = ['WPHPTests\\TestModules\\SampleModule\\SampleModule', 'WPHPTests\\TestModules\\AnotherSampleModule\\AnotherSampleModule'];
     $scanner = new ArrayScanner($array);
     $validModules = $scanner->getValidModules();
     $this->assertSame($validModules, $array);
 }
Example #2
0
 /**
  * @param array $parsedModules
  * @return false|array false on failure, array with module classes on success
  */
 public function routeAll($parsedModules)
 {
     if (!is_array($parsedModules) || empty($parsedModules)) {
         return false;
     }
     $dirScanner = new DirectoryScanner();
     $arrayScanner = new ArrayScanner();
     $buffer = [];
     foreach ($parsedModules as $module) {
         if (empty($module['type']) || empty($module['string'])) {
             continue;
         }
         if ($module['type'] == 'dir') {
             $dirScanner->scanDirectory($module['string']);
         } elseif ($module['type'] == 'class') {
             $buffer[] = $module['string'];
         }
     }
     $arrayScanner->scanArray($buffer);
     $modules = array_unique(array_merge($dirScanner->getValidModules(), $arrayScanner->getValidModules()));
     return $modules;
 }