Exemplo n.º 1
0
 /**
  * @param string $string
  *
  * @return string
  */
 private function convertStringToPattern($string)
 {
     if (MatchUtil::isRegex($string)) {
         return $string;
     } else {
         return MatchUtil::convertGlob($string);
     }
 }
Exemplo n.º 2
0
 /**
  * {@inheritDoc}
  */
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $container = $this->getApplication()->getContainer();
     $table = $this->getHelperSet()->get('table');
     // set up
     if (null === $input->getOption('pattern')) {
         throw new Exception\OptionNotProvidedException('pattern');
     }
     if (null === $input->getOption('dir')) {
         $input->setOption('dir', getcwd());
     }
     // filter listener
     $filter = $input->getOption('filter');
     $inspectorFilters = array();
     $listenerFilters = array();
     if (is_array($filter)) {
         foreach ($filter as $f) {
             if (MatchUtil::isMatch($f)) {
                 $inspectorFilters[] = $f;
             } else {
                 $listenerFilters[] = $f;
             }
         }
     } else {
         if (MatchUtil::isMatch($filter)) {
             $inspectorFilters[] = $f;
         } else {
             $listenerFilters[] = $f;
         }
     }
     $container['inspector.filter_listener']->setFilters($listenerFilters);
     // inspector
     $inspector = $container['inspector'];
     $suspects = $inspector->inspect($input->getOption('dir'), $input->getOption('pattern'), $inspectorFilters);
     $table->setHead(array('id', 'file'));
     $j = 1;
     $rows = array_map(function ($suspect) use(&$j) {
         return array($j++, $suspect->getRelativePathName());
     }, $suspects->getArrayCopy());
     $table->setBody($rows);
     $table->render($output);
 }