Completed
Push — master ( 6e4d29...c8305f )
by Alessandro
02:31
created

InfluxDbClientFactoryTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 51.43 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 4
dl 18
loc 35
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A test_client_factory_test_exists() 0 5 1
A test_build_udp_client_returns_a_valid_client() 9 9 1
A test_build_http_client_returns_a_valid_client() 9 9 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
//declare(strict_types=1);
0 ignored issues
show
Unused Code Comprehensibility introduced by
72% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
3
4
namespace Algatux\InfluxDbBundle\Tests\unit\Services\Clients;
5
6
use Algatux\InfluxDbBundle\Services\Clients\InfluxDbClientFactory;
7
use InfluxDB\Client;
8
use InfluxDB\Database;
9
use InfluxDB\Driver\Guzzle;
10
use InfluxDB\Driver\UDP;
11
12
class InfluxDbClientFactoryTest extends \PHPUnit_Framework_TestCase
13
{
14
15
    const TEST_HOST = 'localhost';
16
    const TEST_DB = 'udp';
17
    const TEST_UDP = '4444';
18
    const TEST_HTTP = '8086';
19
20
    public function test_client_factory_test_exists()
21
    {
22
        $factory = new InfluxDbClientFactory(self::TEST_HOST,self::TEST_DB,self::TEST_UDP,self::TEST_HTTP);
23
        $this->assertInstanceOf(InfluxDbClientFactory::class, $factory);
24
    }
25
26 View Code Duplication
    public function test_build_udp_client_returns_a_valid_client()
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
        $factory = new InfluxDbClientFactory(self::TEST_HOST,self::TEST_DB,self::TEST_UDP,self::TEST_HTTP);
29
        $database = $factory->buildUdpClient();
30
31
        $this->assertInstanceOf(Database::class, $database);
32
        $this->assertEquals(self::TEST_DB, $database->getName());
33
        $this->assertInstanceOf(UDP::class,$database->getClient()->getDriver());
34
    }
35
36 View Code Duplication
    public function test_build_http_client_returns_a_valid_client()
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...
37
    {
38
        $factory = new InfluxDbClientFactory(self::TEST_HOST,self::TEST_DB,self::TEST_UDP,self::TEST_HTTP);
39
        $database = $factory->buildHttpClient();
40
41
        $this->assertInstanceOf(Database::class, $database);
42
        $this->assertEquals(self::TEST_DB, $database->getName());
43
        $this->assertInstanceOf(Guzzle::class,$database->getClient()->getDriver());
44
    }
45
46
}
47