ReviewFileProcessor::process()   C
last analyzed

Complexity

Conditions 7
Paths 11

Size

Total Lines 32
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 56

Importance

Changes 0
Metric Value
dl 0
loc 32
c 0
b 0
f 0
ccs 0
cts 22
cp 0
rs 6.7272
cc 7
eloc 15
nc 11
nop 2
crap 56
1
<?php
2
3
  namespace Funivan\Cs\FileProcessor;
4
5
  use Funivan\Cs\Fs\FilesCollection;
6
  use Funivan\Cs\Report\Report;
7
8
  /**
9
   * @author Ivan Shcherbak <[email protected]> 2016
10
   */
11
  class ReviewFileProcessor extends BaseFileProcessor {
12
13
14
    /**
15
     * @param FilesCollection $files
16
     * @param Report $report
17
     */
18
    public function process(FilesCollection $files, Report $report) {
19
20
      $isDebug = $this->getOutput()->isDebug();
21
22
      foreach ($files as $file) {
23
        $errorsNum = $report->count();
24
25
        if ($isDebug) {
26
          $this->getOutput()->writeln('⚑ open  : ' . $file->getPath());
27
        }
28
29
        foreach ($this->getTools() as $tool) {
30
31
          if (!$tool->canProcess($file)) {
32
            continue;
33
          }
34
35
          $tool->process($file, $report);
36
          if ($errorsNum === $report->count()) {
37
            if ($isDebug) {
38
39
              $this->getOutput()->writeln('✔ ok    : ' . $tool->getDescription() . ' (' . $tool->getName() . ')');
40
            }
41
            continue;
42
          }
43
44
45
          $this->getOutput()->writeln('✘ error : ' . $tool->getDescription() . ' (' . $tool->getName() . ')');
46
        }
47
      }
48
49
    }
50
51
  }