Completed
Push — master ( 2e5350...f0c5b4 )
by Tobias
10:07
created

ExcludeTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 2
c 2
b 1
f 0
lcom 1
cbo 2
dl 19
loc 19
rs 10

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 Happyr\SerializerBundle\Tests\Functional;
4
5
use Happyr\SerializerBundle\Tests\Fixtures\Exclude\Car;
6
7
class ExcludeTest extends SerializerTestCase
8
{
9
    public function testSerialize()
10
    {
11
        $data = $this->serialize(new Car(true));
12
13
        $this->assertFalse(isset($data['model']));
14
        $this->assertTrue(isset($data['size']));
15
    }
16
17
    public function testDeserialize()
18
    {
19
        $data = ['model' => 'model_value', 'size' => 'size_value'];
20
        $obj = $this->deserialize($data, Car::class);
21
22
        $this->assertPropertyValue($obj, 'model', null);
23
        $this->assertPropertyValue($obj, 'size', 'size_value');
24
    }
25
}
26