Completed
Push — master ( fef923...c0df34 )
by Rafael
03:03
created

Array2ObjectContextTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 45
Duplicated Lines 53.33 %

Coupling/Cohesion

Components 1
Dependencies 6

Importance

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

5 Methods

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