Completed
Pull Request — master (#1)
by Harry
03:02
created

ExceptionTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 81.48 %

Coupling/Cohesion

Components 1
Dependencies 3
Metric Value
wmc 4
lcom 1
cbo 3
dl 22
loc 27
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testConnectionException() 11 11 2
A testConfigurationException() 11 11 2

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 Graze\DogStatsD\Test\Unit;
4
5
use Graze\DogStatsD\Exception\ConnectionException;
6
use Graze\DogStatsD\Exception\ConfigurationException;
7
use Graze\DogStatsD\Client;
8
use Graze\DogStatsD\Test\TestCase;
9
10
class ExceptionTest extends TestCase
11
{
12 View Code Duplication
    public function testConnectionException()
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...
13
    {
14
        try {
15
            throw new ConnectionException($this->client, 'Could not connect');
16
        } catch (ConnectionException $e) {
17
            $client = $e->getInstance();
18
            $this->assertTrue($client instanceof Client);
19
            $this->assertEquals('Could not connect', $e->getMessage());
20
            return;
21
        }
22
    }
23
24
25 View Code Duplication
    public function testConfigurationException()
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...
26
    {
27
        try {
28
            throw new ConfigurationException($this->client, 'Configuration error');
29
        } catch (ConfigurationException $e) {
30
            $client = $e->getInstance();
31
            $this->assertTrue($client instanceof Client);
32
            $this->assertEquals('Configuration error', $e->getMessage());
33
            return;
34
        }
35
    }
36
}
37