CountryMapperTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 4
dl 16
loc 16
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testMapArrayToCollection() 5 5 1
A testMapArrayToEntity() 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
namespace GeoBase\Countries\Tests\Country;
4
5
use GeoBase\Countries\Country\CountryEntity;
6
use GeoBase\Countries\Country\CountryLoader;
7
use GeoBase\Countries\Country\CountryMapper;
8
use PHPUnit\Framework\TestCase;
9
10 View Code Duplication
class CountryMapperTest extends TestCase
0 ignored issues
show
Duplication introduced by
This class 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...
11
{
12
    public function testMapArrayToCollection()
13
    {
14
        $collection = (new CountryMapper())->mapArrayToCollection((new CountryLoader())->loadAllCountries());
15
        $this->assertGreaterThan(1, count($collection));
16
    }
17
18
    public function testMapArrayToEntity()
19
    {
20
        $countries = (new CountryLoader())->loadAllCountries();
21
        $entity = (new CountryMapper())->mapArrayToEntity($countries[0]);
22
        $this->assertInstanceOf(CountryEntity::class, $entity);
23
        $this->assertNotEmpty($entity->getCode());
24
    }
25
}
26