InBetweenMethodSpacingSniffTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 32 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 8
loc 25
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testDetection() 8 8 1
A testFixing() 0 10 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
declare(strict_types = 1);
4
5
namespace Zenify\CodingStandard\Tests\Sniffs\WhiteSpace\InBetweenMethodSpacing;
6
7
use PHPUnit\Framework\TestCase;
8
use Zenify\CodingStandard\Tests\CodeSnifferRunner;
9
use ZenifyCodingStandard\Sniffs\WhiteSpace\InBetweenMethodSpacingSniff;
10
11
12
final class InBetweenMethodSpacingSniffTest extends TestCase
13
{
14
15 View Code Duplication
	public function testDetection()
16
	{
17
		$codeSnifferRunner = new CodeSnifferRunner(InBetweenMethodSpacingSniff::NAME);
18
19
		$this->assertSame(1, $codeSnifferRunner->getErrorCountInFile(__DIR__ . '/wrong.php'));
20
		$this->assertSame(1, $codeSnifferRunner->getErrorCountInFile(__DIR__ . '/wrong2.php'));
21
		$this->assertSame(0, $codeSnifferRunner->getErrorCountInFile(__DIR__ . '/correct.php'));
22
	}
23
24
25
	public function testFixing()
26
	{
27
		$codeSnifferRunner = new CodeSnifferRunner(InBetweenMethodSpacingSniff::NAME);
28
29
		$fixedContent = $codeSnifferRunner->getFixedContent(__DIR__ . '/wrong.php');
30
		$this->assertSame(file_get_contents(__DIR__ . '/wrong-fixed.php'), $fixedContent);
31
32
		$fixedContent = $codeSnifferRunner->getFixedContent(__DIR__ . '/wrong2.php');
33
		$this->assertSame(file_get_contents(__DIR__ . '/wrong-fixed.php'), $fixedContent);
34
	}
35
36
}
37