| Total Complexity | 5 |
| Total Lines | 55 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 10 | class DalliClient |
||
| 11 | { |
||
| 12 | /** |
||
| 13 | * @var ClientInterface |
||
| 14 | */ |
||
| 15 | private $client; |
||
| 16 | /** |
||
| 17 | * @var string |
||
| 18 | */ |
||
| 19 | private $dalliEndpoint; |
||
| 20 | /** @var array */ |
||
| 21 | private $errors = []; |
||
| 22 | /** @var ResponseInterface */ |
||
| 23 | private $response; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * DalliClient constructor. |
||
| 27 | * @param string $dalliEndpoint |
||
| 28 | * @param ClientInterface $client |
||
| 29 | */ |
||
| 30 | 2 | public function __construct(string $dalliEndpoint, ClientInterface $client) |
|
| 31 | { |
||
| 32 | 2 | $this->client = $client; |
|
| 33 | 2 | $this->dalliEndpoint = $dalliEndpoint; |
|
| 34 | 2 | } |
|
| 35 | |||
| 36 | /** |
||
| 37 | * @return bool |
||
| 38 | */ |
||
| 39 | 2 | private function parseErrors(): bool |
|
| 40 | { |
||
| 41 | 2 | $pattern = '/errorMessage=\'(.+)\'/'; |
|
| 42 | 2 | if (preg_match_all($pattern, $this->response->getBody()->getContents(), $matches)) { |
|
| 43 | 1 | $this->errors = $matches[1]; |
|
| 44 | 1 | return false; |
|
| 45 | } |
||
| 46 | 1 | return true; |
|
| 47 | } |
||
| 48 | |||
| 49 | /** |
||
| 50 | * @param string $body Body as XML string |
||
| 51 | * @return boolean |
||
| 52 | * @throws GuzzleException |
||
| 53 | */ |
||
| 54 | 2 | public function sendApiRequest(string $body): bool |
|
| 60 | } |
||
| 61 | |||
| 62 | 1 | public function getErrors() |
|
| 67 |