Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
CodeMessDetector.php
Go to the documentation of this file.
1 <?php
11 
12 use \Magento\TestFramework\CodingStandard\ToolInterface;
13 
15 {
21  private $rulesetFile;
22 
28  private $reportFile;
29 
36  public function __construct($rulesetFile, $reportFile)
37  {
38  $this->reportFile = $reportFile;
39  $this->rulesetFile = $rulesetFile;
40  }
41 
47  public function canRun()
48  {
49  return class_exists(\PHPMD\TextUI\Command::class);
50  }
51 
55  public function run(array $whiteList)
56  {
57  if (empty($whiteList)) {
58  return \PHPMD\TextUI\Command::EXIT_SUCCESS;
59  }
60 
61  $commandLineArguments = [
62  'run_file_mock', //emulate script name in console arguments
63  implode(',', $whiteList),
64  'text', //report format
65  $this->rulesetFile,
66  '--reportfile',
67  $this->reportFile,
68  ];
69 
70  $options = new \PHPMD\TextUI\CommandLineOptions($commandLineArguments);
71 
72  $command = new \PHPMD\TextUI\Command();
73 
74  return $command->run($options, new \PHPMD\RuleSetFactory());
75  }
76 }