AbstractLineAfterOpenTag   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 88.24%

Importance

Changes 0
Metric Value
dl 0
loc 46
c 0
b 0
f 0
wmc 6
lcom 0
cbo 4
ccs 15
cts 17
cp 0.8824
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A canProcess() 0 3 1
B getInvalidStartTokens() 0 30 5
1
<?php
2
3
  namespace Funivan\Cs\Tools\Php\LineAfterOpenTag;
4
5
  use Funivan\Cs\FileTool\FileTool;
6
  use Funivan\Cs\Fs\File;
7
  use Funivan\Cs\Fs\FileFilter;
8
  use Funivan\PhpTokenizer\Collection;
9
10
  /**
11
   *
12
   */
13
  abstract class AbstractLineAfterOpenTag implements FileTool {
14
15
    /**
16
     * @inheritdoc
17
     */
18
    public function canProcess(File $file) {
19
      return (new FileFilter())->notDeleted()->extension(['php'])->isValid($file);
20
    }
21
22
23
    /**
24
     * @param Collection $collection
25
     * @return LineTokenData[]
26
     */
27 13
    protected function getInvalidStartTokens(Collection $collection) {
28
29
30 13
      $data = [];
31
32
33 13
      foreach ($collection as $tag) {
34 13
        if (T_OPEN_TAG !== $tag->getType()) {
35 13
          continue;
36
        }
37
38
39 13
        $value = $tag->getValue();
40 13
        $next = $collection->getNext();
41 13
        $whitespaceToken = null;
42 13
        if ($next->getType() === T_WHITESPACE) {
43 12
          $value = $value . $next->getValue();
44 12
          $whitespaceToken = $next;
45
        }
46
47
48 13
        $num = count(explode("\n", $value));
49 13
        if ($num !== 3) {
50 13
          $data[] = new LineTokenData($num, $tag, $whitespaceToken);
51
        }
52
53
      }
54
55 13
      return $data;
56
    }
57
58
  }