Beispiel #1
0
 /**
  * {@inheritdoc}
  */
 public function execute(CommandParams $params, CommandExecutionContext $executionContext)
 {
     $fileName = $params->getFirstArgument();
     if (is_readable($fileName)) {
         $contents = file_get_contents($fileName);
     } else {
         if (!$executionContext->hasFileInWorkingDirectory($fileName)) {
             throw new ExecutionFailedException("File '{$fileName}' does not exist.");
         }
         $contents = $executionContext->getContentsOfFileInWorkingDirectory($fileName);
     }
     switch ($params->getSecondArgument()) {
         case 'class':
             return $this->findClass($contents, $params, $fileName);
         case 'abstract':
             return $this->findAbstract($contents);
         case 'method':
             return $this->findMethod($contents, $params, $fileName);
         case 'function':
             return $this->findFunction($contents, $params, $fileName);
         case 'line':
             return $this->findLines($contents, $params);
         default:
             return $this->wrapLines($contents);
     }
 }