Passed
Pull Request — master (#896)
by Songda
01:56
created

OriginResponseDirection   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 12
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A guide() 0 7 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yansongda\Pay\Direction;
6
7
use Psr\Http\Message\ResponseInterface;
8
use Yansongda\Pay\Contract\DirectionInterface;
9
use Yansongda\Pay\Contract\PackerInterface;
10
use Yansongda\Pay\Exception\Exception;
11
use Yansongda\Pay\Exception\InvalidResponseException;
12
13
class OriginResponseDirection implements DirectionInterface
14
{
15
    /**
16
     * @throws InvalidResponseException
17
     */
18
    public function guide(PackerInterface $packer, ?ResponseInterface $response): ?ResponseInterface
19
    {
20
        if (!is_null($response)) {
21
            return $response;
22
        }
23
24
        throw new InvalidResponseException(Exception::INVALID_RESPONSE_CODE);
25
    }
26
}
27