Completed
Push — master ( 0496dc...50ef2b )
by Shcherbak
02:37
created

LineEndingFixer   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
c 1
b 0
f 1
lcom 0
cbo 3
dl 0
loc 32
ccs 9
cts 9
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getName() 0 3 1
A process() 0 11 2
1
<?php
2
3
  namespace Funivan\Cs\Tools\LineEnding;
4
5
  use Funivan\Cs\FileFinder\FileInfo;
6
  use Funivan\Cs\Message\Report;
7
8
  /**
9
   *
10
   */
11
  class LineEndingFixer extends LineEndingAbstract {
12
13
    const NAME = 'line_ending_fixer';
14
15
16
    /**
17
     * @codeCoverageIgnore
18
     * @inheritdoc
19
     */
20
    public function getName() {
21
      return self::NAME;
22
    }
23
24
25
    /**
26
     * @param FileInfo $file
27
     * @param Report $report
28
     * @void
29
     */
30 4
    public function process(FileInfo $file, Report $report) {
31 4
      $tokens = $this->getInvalidStartTokens($file);
32
33 4
      foreach ($tokens as $token) {
34 2
        $value = $token->getValue();
35 2
        $value = preg_replace(self::REGEX, "\n", $value);
36 2
        $token->setValue($value);
37
38 2
        $report->addNotice($file, $this, 'Replace invalid line ending', $token->getLine());
39 4
      }
40 4
    }
41
42
  }