Completed
Pull Request — master (#64)
by Márk
05:20
created

ErrorPlugin::handleRequest()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 4
Bugs 1 Features 0
Metric Value
c 4
b 1
f 0
dl 0
loc 8
ccs 5
cts 5
cp 1
rs 9.4285
cc 1
eloc 4
nc 1
nop 3
crap 1
1
<?php
2
3
namespace Http\Client\Plugin;
4
5
use Http\Client\Plugin\Exception\ClientErrorException;
6
use Http\Client\Plugin\Exception\ServerErrorException;
7
use Psr\Http\Message\RequestInterface;
8
use Psr\Http\Message\ResponseInterface;
9
10
/**
11
 * @author Joel Wurtz <[email protected]>
12
 *
13
 * @deprecated since version 1.1, to be removed in 2.0. Use {@link \Http\Client\Common\Plugin\ErrorPlugin} instead.
14
 */
15
class ErrorPlugin extends \Http\Client\Common\Plugin\ErrorPlugin implements Plugin
0 ignored issues
show
Deprecated Code introduced by
The interface Http\Client\Plugin\Plugin has been deprecated with message: since version 1.1, to be removed in 2.0. Use {@link \Http\Client\Common\Plugin} instead.

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
16
{
17
    /**
18
     * {@inheritdoc}
19
     */
20 3
    protected function transformResponseToException(RequestInterface $request, ResponseInterface $response)
21
    {
22 3 View Code Duplication
        if ($response->getStatusCode() >= 400 && $response->getStatusCode() < 500) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
23 1
            throw new ClientErrorException($response->getReasonPhrase(), $request, $response);
0 ignored issues
show
Deprecated Code introduced by
The class Http\Client\Plugin\Exception\ClientErrorException has been deprecated with message: since version 1.1, to be removed in 2.0. Use {@link \Http\Client\Common\Exception\ClientErrorException} instead.

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
24
        }
25
26 2 View Code Duplication
        if ($response->getStatusCode() >= 500 && $response->getStatusCode() < 600) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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 1
            throw new ServerErrorException($response->getReasonPhrase(), $request, $response);
0 ignored issues
show
Deprecated Code introduced by
The class Http\Client\Plugin\Exception\ServerErrorException has been deprecated with message: since version 1.1, to be removed in 2.0. Use {@link \Http\Client\Common\Exception\ServerErrorException} instead.

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
28
        }
29
30 1
        return $response;
31
    }
32
}
33