Completed
Push — master ( bfc368...43106f )
by Shcherbak
02:26
created

LineAfterOpenTagReview::process()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 12
rs 9.4285
cc 3
eloc 6
nc 3
nop 2
1
<?php
2
3
  namespace Funivan\Cs\Tools\Php\LineAfterOpenTag;
4
5
  use Funivan\Cs\FileFinder\FileInfo;
6
  use Funivan\Cs\Message\Report;
7
8
  /**
9
   *
10
   */
11
  class LineAfterOpenTagReview extends AbstractLineAfterOpenTag {
12
13
    const NAME = 'php_line_after_open_tag_review';
14
15
16
    /**
17
     * @return string
18
     */
19
    public function getDescription() {
20
      return 'Expect one empty line after php open tag';
21
    }
22
23
24
    /**
25
     * Return unique string of the tool
26
     * Review tools should have ending `_review`
27
     * Fixer tools should have ending `_fixer`
28
     *
29
     * @return string
30
     */
31
    public function getName() {
32
      return self::NAME;
33
    }
34
35
36
    /**
37
     * @param FileInfo $file
38
     * @param Report $report
39
     */
40
    public function process(FileInfo $file, Report $report) {
41
42
      $items = $this->getInvalidStartTokens($file);
43
44
      if (count($items) === 0) {
45
        return;
46
      }
47
      foreach ($items as $lineTokenData) {
48
        $report->addError($file, $this, 'Expect at one empty line after php open tag', $lineTokenData->getToken()->getLine());
49
      }
50
51
    }
52
53
  }