Completed
Push — next ( 3fc9f0...5d2fc6 )
by Jonathan
9s
created

KintTestCase   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 41
Duplicated Lines 34.15 %

Coupling/Cohesion

Components 1
Dependencies 6

Importance

Changes 0
Metric Value
dl 14
loc 41
rs 10
c 0
b 0
f 0
wmc 4
lcom 1
cbo 6

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 7 7 1
A tearDown() 7 7 1
A assertLike() 0 8 2

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
namespace Kint\Test;
4
5
use Kint;
6
use Kint\Object\BlobObject;
7
use Kint\Renderer\TextRenderer;
8
use PHPUnit_Framework_TestCase;
9
use PHPUnit_Util_InvalidArgumentHelper;
10
11
abstract class KintTestCase extends PHPUnit_Framework_TestCase
0 ignored issues
show
Coding Style introduced by
KintTestCase does not seem to conform to the naming convention (^Abstract|Factory$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
Coding Style introduced by
The property $kint_status is not named in camelCase.

This check marks property names that have not been written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes databaseConnectionString.

Loading history...
Coding Style introduced by
The property $char_encodings is not named in camelCase.

This check marks property names that have not been written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes databaseConnectionString.

Loading history...
Coding Style introduced by
The property $text_decorations is not named in camelCase.

This check marks property names that have not been written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes databaseConnectionString.

Loading history...
Coding Style introduced by
The property $text_plugin_whitelist is not named in camelCase.

This check marks property names that have not been written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes databaseConnectionString.

Loading history...
12
{
13
    protected $kint_status;
0 ignored issues
show
Coding Style introduced by
$kint_status does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
14
    protected $char_encodings;
0 ignored issues
show
Coding Style introduced by
$char_encodings does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
15
    protected $text_decorations;
0 ignored issues
show
Coding Style introduced by
$text_decorations does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
16
    protected $text_plugin_whitelist;
0 ignored issues
show
Coding Style introduced by
$text_plugin_whitelist does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
Comprehensibility Naming introduced by
The variable name $text_plugin_whitelist exceeds the maximum configured length of 20.

Very long variable names usually make code harder to read. It is therefore recommended not to make variable names too verbose.

Loading history...
17
18 View Code Duplication
    public function setUp()
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...
19
    {
20
        $this->kint_status = Kint::settings();
21
        $this->char_encodings = BlobObject::$char_encodings;
22
        $this->text_decorations = TextRenderer::$decorations;
23
        $this->text_plugin_whitelist = TextRenderer::$parser_plugin_whitelist;
24
    }
25
26 View Code Duplication
    public function tearDown()
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
        Kint::settings($this->kint_status);
29
        BlobObject::$char_encodings = $this->char_encodings;
30
        TextRenderer::$decorations = $this->text_decorations;
31
        TextRenderer::$parser_plugin_whitelist = $this->text_plugin_whitelist;
32
    }
33
34
    /**
35
     * Asserts that a condition is true.
36
     *
37
     * @param array  $expected
38
     * @param string $actual
39
     * @param string $message
40
     *
41
     * @throws PHPUnit_Framework_Exception
42
     */
43
    public function assertLike(array $expected, $actual, $message = '')
44
    {
45
        if (!is_string($actual)) {
46
            throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'string');
47
        }
48
49
        self::assertThat($actual, new ContainsInOrderConstraint($expected), $message);
50
    }
51
}
52