Array2ObjectContextTest   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 45
Duplicated Lines 84.44 %

Coupling/Cohesion

Components 1
Dependencies 6

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 6
dl 38
loc 45
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A testGetSetParsers() 8 8 1
A testAppendParsers() 8 8 1
A testPrependParsers() 8 8 1
A testGetSetPropertyMatcher() 7 7 1
A testGetSetPropertyWriter() 7 7 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
/*
4
 * This file is part of the rafrsr/lib-array2object package.
5
 *
6
 * (c) Rafael SR <https://github.com/rafrsr>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
namespace Rafrsr\LibArray2Object\Tests;
12
13
use Rafrsr\LibArray2Object\Array2ObjectContext;
14
use Rafrsr\LibArray2Object\Matcher\CamelizeMatcher;
15
use Rafrsr\LibArray2Object\Parser\IntegerParser;
16
use Rafrsr\LibArray2Object\Parser\StringParser;
17
use Rafrsr\LibArray2Object\Writer\AccessorWriter;
18
19
class Array2ObjectContextTest extends \PHPUnit_Framework_TestCase
20
{
21 View Code Duplication
    public function testGetSetParsers()
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...
22
    {
23
        $context = new Array2ObjectContext();
24
        $parsers = [new StringParser(), new IntegerParser()];
25
        $context->setParsers($parsers);
26
27
        static::assertEquals(['string' => new StringParser(), 'integer' => new IntegerParser()], $context->getParsers());
28
    }
29
30 View Code Duplication
    public function testAppendParsers()
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...
31
    {
32
        $context = new Array2ObjectContext();
33
        $parsers = [new StringParser()];
34
        $context->setParsers($parsers);
35
        $context->appendParser(new IntegerParser());
36
        static::assertEquals(['string' => new StringParser(), 'integer' => new IntegerParser()], $context->getParsers());
37
    }
38
39 View Code Duplication
    public function testPrependParsers()
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...
40
    {
41
        $context = new Array2ObjectContext();
42
        $parsers = [new StringParser(), new IntegerParser()];
43
        $context->setParsers($parsers);
44
        $context->prependParser(new IntegerParser());
45
        static::assertEquals(['integer' => new IntegerParser(), 'string' => new StringParser()], $context->getParsers());
46
    }
47
48 View Code Duplication
    public function testGetSetPropertyMatcher()
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...
49
    {
50
        $context = new Array2ObjectContext();
51
        $matcher = new CamelizeMatcher();
52
        $context->setMatcher($matcher);
53
        static::assertEquals($matcher, $context->getMatcher());
54
    }
55
56 View Code Duplication
    public function testGetSetPropertyWriter()
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...
57
    {
58
        $context = new Array2ObjectContext();
59
        $writer = new AccessorWriter();
60
        $context->setWriter($writer);
61
        static::assertEquals($writer, $context->getWriter());
62
    }
63
}
64