Passed
Pull Request — master (#13)
by
unknown
02:17
created

VerificationServiceFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 6
c 1
b 0
f 0
dl 0
loc 17
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A createFromCustomerVerificationResponse() 0 10 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Skrill\Factory;
6
7
use Psr\Http\Message\ResponseInterface;
8
use Skrill\Exception\SkrillResponseException;
9
use Skrill\Response\Response;
10
11
/**
12
 * Class VerificationServiceFactory
13
 */
14
final class VerificationServiceFactory
15
{
16
    /**
17
     * @param ResponseInterface $response
18
     * @return Response
19
     * @throws SkrillResponseException
20
     */
21
    public static function createFromCustomerVerificationResponse(ResponseInterface $response)
22
    {
23
        $content = $response->getBody()->getContents();
24
        $result = json_decode($content, true);
25
26
        if (JSON_ERROR_NONE == json_last_error()) {
27
            throw SkrillResponseException::fromSkillError($result->message);
28
        }
29
30
        return new Response($result);
31
    }
32
}
33