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

OriginResponseDirection::guide()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 2
dl 0
loc 7
rs 10
c 0
b 0
f 0
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