LineAfterOpenTagReview   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 7

Test Coverage

Coverage 83.33%

Importance

Changes 0
Metric Value
dl 0
loc 44
c 0
b 0
f 0
wmc 5
lcom 0
cbo 7
ccs 10
cts 12
cp 0.8333
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getDescription() 0 3 1
A getName() 0 3 1
A process() 0 13 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
  }