CodeStyleTest::testKeepSpaces()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 10
Ratio 100 %

Importance

Changes 0
Metric Value
dl 10
loc 10
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 7
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Zenify\DoctrineMigrations\Tests\CodeStyle;
6
7
use PHPUnit\Framework\TestCase;
8
use Zenify\DoctrineMigrations\CodeStyle\CodeStyle;
9
10
11
final class CodeStyleTest extends TestCase
12
{
13
14 View Code Duplication
	public function testConvertToTabs()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
15
	{
16
		$file = sys_get_temp_dir() . '/doctrine-migrations/some-spaced-text-file.txt';
17
		@mkdir(dirname($file));
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
18
		file_put_contents($file, '    hi');
19
		(new CodeStyle(CodeStyle::INDENTATION_TABS))->applyForFile($file);
20
21
		$this->assertStringNotEqualsFile($file, '    hi');
22
		$this->assertStringEqualsFile($file, "\thi");
23
	}
24
25
26 View Code Duplication
	public function testKeepSpaces()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
27
	{
28
		$file = sys_get_temp_dir() . '/doctrine-migrations/some-spaced-text-file.txt';
29
		@mkdir(dirname($file));
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
30
		file_put_contents($file, '    hi');
31
		(new CodeStyle(CodeStyle::INDENTATION_SPACES))->applyForFile($file);
32
33
		$this->assertStringEqualsFile($file, '    hi');
34
		$this->assertStringNotEqualsFile($file, "\thi");
35
	}
36
37
}
38