Potsky\LaravelLocalizationHelpers\Factory\Localization::fixCodeStyle PHP Метод

fixCodeStyle() публичный Метод

Fix Code Style for a file or a directory
public fixCodeStyle ( $filePath, array $fixers, $level = null )
$fixers array
    public function fixCodeStyle($filePath, array $fixers, $level = null)
    {
        if (defined('HHVM_VERSION_ID') && HHVM_VERSION_ID < 30500) {
            throw new Exception("HHVM needs to be a minimum version of HHVM 3.5.0");
        } elseif (!defined('PHP_VERSION_ID') || PHP_VERSION_ID < 50306) {
            throw new Exception("PHP needs to be a minimum version of PHP 5.3.6");
        }
        // @codeCoverageIgnoreEnd
        if (!file_exists($filePath)) {
            throw new Exception('File "' . $filePath . '" does not exist, cannot fix it');
        }
        $options = array('--no-interaction' => true, 'command' => 'fix', 'path' => $filePath);
        $fix = array();
        foreach ($fixers as $fixer) {
            if ($this->isAFixer($fixer)) {
                $fix[] = $fixer;
            }
        }
        $options['--fixers'] = implode(',', $fix);
        if ($this->isALevel($level)) {
            $options['--level'] = $level;
        }
        $input = new ArrayInput($options);
        $output = new BufferedOutput();
        $application = new \Symfony\CS\Console\Application();
        $application->setAutoExit(false);
        $application->run($input, $output);
        return $output->fetch();
    }

Usage Example

 /**
  *
  */
 public function testPathDoesNotExist()
 {
     $messageBag = new MessageBag();
     $manager = new Localization($messageBag);
     $this->setExpectedException('\\Potsky\\LaravelLocalizationHelpers\\Factory\\Exception');
     $manager->fixCodeStyle(self::LANG_DIR_PATH . '/file_does_not_exist', array('align_double_arrow', 'short_array_syntax'));
 }