Total Complexity | 5 |
Total Lines | 52 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
18 | final class SidFactory |
||
19 | { |
||
20 | /** |
||
21 | * @param string $value |
||
22 | * |
||
23 | * @return Sid |
||
24 | * |
||
25 | * @throws InvalidSidException |
||
26 | * @throws Exception |
||
27 | */ |
||
28 | public static function createFromString(string $value): Sid |
||
31 | } |
||
32 | |||
33 | /** |
||
34 | * @param ResponseInterface $response |
||
35 | * |
||
36 | * @return Sid |
||
37 | * |
||
38 | * @throws InvalidSidException |
||
39 | * @throws SkrillResponseException |
||
40 | */ |
||
41 | public static function createFromXMLResponse(ResponseInterface $response): Sid |
||
42 | { |
||
43 | $xml = new SimpleXMLElement($response->getBody()->getContents()); |
||
44 | |||
45 | if ($xml->xpath('error/error_msg')) { |
||
46 | throw SkrillResponseException::fromSkillError((strval($xml->error->error_msg))); |
||
47 | } |
||
48 | |||
49 | return self::createFromString(strval($xml->sid)); |
||
50 | } |
||
51 | |||
52 | /** |
||
53 | * @param ResponseInterface $response |
||
54 | * |
||
55 | * @return Sid |
||
56 | * |
||
57 | * @throws InvalidSidException |
||
58 | * @throws SkrillResponseException |
||
59 | */ |
||
60 | public static function createFromSaleResponse(ResponseInterface $response): Sid |
||
70 | } |
||
71 | } |
||
72 |