Completed
Push — master ( d8cc04...be84ec )
by Shcherbak
04:06
created

LineBeforeClassEndReview::process()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 8
c 0
b 0
f 0
ccs 6
cts 6
cp 1
rs 9.4285
cc 2
eloc 5
nc 2
nop 2
crap 2
1
<?php
2
3
  namespace Funivan\Cs\Tools\Php\LineBeforeClassEnd;
4
5
  use Funivan\Cs\Fs\File;
6
  use Funivan\Cs\Report\Report;
7
8
  /**
9
   *
10
   */
11
  class LineBeforeClassEndReview extends AbstractLineBeforeClassEnd {
12
13
    const NAME = 'php_line_before_class_end_review';
14
15
16
    /**
17
     * @inheritdoc
18
     */
19 1
    public function getName() {
20 1
      return self::NAME;
21
    }
22
23
24
    /**
25
     * @inheritdoc
26
     */
27
    public function getDescription() {
28
      return 'Check if there is one empty line before class closing tag';
29
    }
30
31
32
    /**
33
     * @param File $file
34
     * @param Report $report
35
     * @void
36
     */
37 1
    public function process(File $file, Report $report) {
38 1
      $collection = \Funivan\PhpTokenizer\Collection::createFromString($file->getContent()->get());
39 1
      $tokens = $this->getInvalidTokens($collection);
40
41 1
      foreach ($tokens as $token) {
42 1
        $report->addMessage($file, $this, 'Expect one empty line before class end', $token->getLine());
43
      }
44 1
    }
45
46
  }