ipagdevs /
ipag-sdk-php
| 1 | <?php |
||
| 2 | |||
| 3 | namespace Ipag\Sdk\Http; |
||
| 4 | |||
| 5 | use Ipag\Sdk\IO\JsonSerializer; |
||
| 6 | use Ipag\Sdk\IO\MutatorInterface; |
||
|
0 ignored issues
–
show
|
|||
| 7 | use Ipag\Sdk\IO\SerializerInterface; |
||
| 8 | use Ipag\Sdk\Util\ArrayUtil; |
||
| 9 | |||
| 10 | class Response |
||
| 11 | { |
||
| 12 | protected ?SerializerInterface $serializer; |
||
| 13 | protected ?array $data; |
||
| 14 | protected ?string $raw; |
||
| 15 | |||
| 16 | protected ?array $headers; |
||
| 17 | |||
| 18 | protected ?int $statusCode; |
||
| 19 | |||
| 20 | protected function __construct(?SerializerInterface $serializer, ?string $body, ?array $headers, ?int $statusCode) |
||
| 21 | { |
||
| 22 | $this->raw = $body; |
||
| 23 | $this->serializer = $serializer; |
||
| 24 | $this->data = null; |
||
| 25 | $this->headers = $headers; |
||
| 26 | $this->statusCode = $statusCode; |
||
| 27 | } |
||
| 28 | |||
| 29 | public function unSerialize(): self |
||
| 30 | { |
||
| 31 | if (empty($this->raw) || gettype(json_decode($this->raw)) === 'string') |
||
| 32 | $this->data = ['data' => $this->raw]; |
||
| 33 | else |
||
| 34 | $this->data = $this->serializer ? $this->serializer->unserialize($this->raw) : null; |
||
| 35 | |||
| 36 | return $this; |
||
| 37 | } |
||
| 38 | |||
| 39 | public function getParsed(): ?array |
||
| 40 | { |
||
| 41 | $this->unSerialize(); |
||
| 42 | |||
| 43 | return [ |
||
| 44 | 'data' => $this->data, |
||
| 45 | 'headers' => $this->headers, |
||
| 46 | 'statusCode' => $this->statusCode |
||
| 47 | ]; |
||
| 48 | } |
||
| 49 | |||
| 50 | public function getParsedPath(string $dotNotation, $default = null) |
||
| 51 | { |
||
| 52 | return ArrayUtil::get('data.' . $dotNotation, $this->getParsed(), $default); |
||
| 53 | } |
||
| 54 | |||
| 55 | public function getBody(): ?string |
||
| 56 | { |
||
| 57 | return $this->raw; |
||
| 58 | } |
||
| 59 | |||
| 60 | public function getHeaders(): ?array |
||
| 61 | { |
||
| 62 | return $this->headers; |
||
| 63 | } |
||
| 64 | |||
| 65 | public function getStatusCode(): ?int |
||
| 66 | { |
||
| 67 | return $this->statusCode; |
||
| 68 | } |
||
| 69 | |||
| 70 | public function getData(): ?array |
||
| 71 | { |
||
| 72 | return $this->data; |
||
| 73 | } |
||
| 74 | |||
| 75 | public function setSerializer(?SerializerInterface $serializer): void |
||
| 76 | { |
||
| 77 | $this->serializer = $serializer; |
||
| 78 | } |
||
| 79 | |||
| 80 | // |
||
| 81 | |||
| 82 | public static function from(?string $data, ?array $headers = null, ?int $statusCode = null): self |
||
| 83 | { |
||
| 84 | return new static(null, $data, $headers, $statusCode); |
||
| 85 | } |
||
| 86 | } |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths