LineAfterOpenTagReview::process()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 13
c 0
b 0
f 0
ccs 8
cts 8
cp 1
rs 9.4285
cc 3
eloc 7
nc 3
nop 2
crap 3
1
<?php
2
3
  namespace Funivan\Cs\Tools\Php\LineAfterOpenTag;
4
5
  use Funivan\Cs\Fs\File;
6
  use Funivan\Cs\Report\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 6
    public function getName() {
32 6
      return self::NAME;
33
    }
34
35
36
    /**
37
     * @param File $file
38
     * @param Report $report
39
     */
40 6
    public function process(File $file, Report $report) {
41
42 6
      $collection = \Funivan\PhpTokenizer\Collection::createFromString($file->getContent()->get());
43 6
      $items = $this->getInvalidStartTokens($collection);
44
45 6
      if (count($items) === 0) {
46 2
        return;
47
      }
48 4
      foreach ($items as $lineTokenData) {
49 4
        $report->addMessage($file, $this, 'Expect at one empty line after php open tag', $lineTokenData->getToken()->getLine());
50
      }
51
52 4
    }
53
54
  }