Completed
Push — master ( 7a83e2...2cf7e5 )
by Shcherbak
02:26
created

SpacesInEmptyLinesReview   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 6
c 1
b 0
f 1
lcom 0
cbo 4
dl 0
loc 47
ccs 0
cts 22
cp 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getName() 0 3 1
A getDescription() 0 3 1
A process() 0 21 4
1
<?php
2
3
  namespace Funivan\Cs\Tools\SpacesInEmptyLines;
4
5
  use Funivan\Cs\FileFinder\FileInfo;
6
  use Funivan\Cs\Message\Report;
7
8
  /**
9
   *
10
   */
11
  class SpacesInEmptyLinesReview extends AbstractSpacesInEmptyLines {
12
13
    const NAME = 'spaces_in_empty_lines_review';
14
15
16
    /**
17
     * @inheritdoc
18
     */
19
    public function getName() {
20
      return self::NAME;
21
    }
22
23
24
    /**
25
     * @return string
26
     */
27
    public function getDescription() {
28
      return 'Check if file contains empty lines with spaces';
29
    }
30
31
32
    /**
33
     * @inheritdoc
34
     */
35
    public function process(FileInfo $file, Report $report) {
36
      $tokens = $this->findTokens($file);
37
38
      if ($tokens->count() === 0) {
39
        return;
40
      }
41
42
      $lines = [];
43
      foreach ($tokens as $token) {
44
        $line = $token->getLine();
45
        $line++; # Our token start in previous line
46
        if (isset($lines[$line])) {
47
          continue;
48
        }
49
50
        $lines[$line] = true;
51
52
        $report->addError($file, $this, 'File contains empty lines with spaces.', $line);
53
      }
54
55
    }
56
57
  }