GuzzleHttpConnectorTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 29.63 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 8
loc 27
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testConnectStandard() 8 8 1
A testConnectWithoutTokent() 0 6 1
A getGuzzleHttpConnector() 0 4 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
 * This file is part of Laravel SMSFactor.
5
 *
6
 * (c) Filippo Galante <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace IlGala\Tests\SMSFactor\Adapters;
13
14
use IlGala\SMSFactor\Adapters\GuzzleHttpAdapter;
15
use IlGala\SMSFactor\Connectors\GuzzleHttpConnector;
16
use GrahamCampbell\TestBench\AbstractTestCase;
17
18
/**
19
 * This is the guzzlehttp connector test class.
20
 *
21
 * @author Filippo Galante <[email protected]>
22
 */
23
class GuzzleHttpConnectorTest extends AbstractTestCase
24
{
25 View Code Duplication
    public function testConnectStandard()
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
        $connector = $this->getGuzzleHttpConnector();
28
29
        $return = $connector->connect(['username' => 'your-username', 'password' => 'your-password', 'accept' => 'application/json']);
30
31
        $this->assertInstanceOf(GuzzleHttpAdapter::class, $return);
32
    }
33
34
    /**
35
     * @expectedException \InvalidArgumentException
36
     * @expectedExceptionMessage The guzzlehttp connector requires configuration.
37
     */
38
    public function testConnectWithoutTokent()
39
    {
40
        $connector = $this->getGuzzleHttpConnector();
41
42
        $connector->connect([]);
43
    }
44
45
    protected function getGuzzleHttpConnector()
46
    {
47
        return new GuzzleHttpConnector();
48
    }
49
}
50