| Total Complexity | 20 |
| Total Lines | 76 |
| Duplicated Lines | 0 % |
| Coverage | 94.44% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 9 | class Response implements ResponseInterface |
||
| 10 | { |
||
| 11 | /** |
||
| 12 | * @var array|null |
||
| 13 | */ |
||
| 14 | private $backtrace; |
||
| 15 | /** |
||
| 16 | * @var array|null |
||
| 17 | */ |
||
| 18 | private $data; |
||
| 19 | /** |
||
| 20 | * @var array|null |
||
| 21 | */ |
||
| 22 | private $note; |
||
| 23 | /** |
||
| 24 | * @var array|null |
||
| 25 | */ |
||
| 26 | private $profile; |
||
| 27 | /** |
||
| 28 | * @var int |
||
| 29 | */ |
||
| 30 | private $type; |
||
| 31 | |||
| 32 | public function __construct(int $t = null, array $r = null, array $b = null, array $p = null, array $n = null) |
||
| 33 | { |
||
| 34 | !$t ?: $this->type = $t; |
||
| 35 | !$r ?: $this->data = $r; |
||
| 36 | 17 | !$b ?: $this->backtrace = $b; |
|
| 37 | !$p ?: $this->profile = $p; |
||
| 38 | 17 | !$n ?: $this->note = $n; |
|
| 39 | 17 | } |
|
| 40 | 17 | ||
| 41 | 17 | public function getType(): ?int |
|
| 42 | 17 | { |
|
| 43 | 17 | return $this->type; |
|
| 44 | } |
||
| 45 | |||
| 46 | public function getData() |
||
| 47 | { |
||
| 48 | 17 | if (!\is_array($this->data)) { |
|
| 49 | return null; |
||
| 50 | 17 | } |
|
| 51 | |||
| 52 | if (isset($this->data[0]['$reql_type$']) && $this->data[0]['$reql_type$'] === 'GROUPED_DATA') { |
||
| 53 | $groups = []; |
||
| 54 | foreach ($this->data[0]['data'] as $group) { |
||
| 55 | $groups[] = [ |
||
| 56 | 17 | 'group' => $group[0], |
|
| 57 | 'reduction' => $group[1], |
||
| 58 | 17 | ]; |
|
| 59 | } |
||
| 60 | |||
| 61 | return $groups; |
||
| 62 | 17 | } |
|
| 63 | |||
| 64 | return \count($this->data) === 1 && array_key_exists(0, $this->data) ? $this->data[0] : $this->data; |
||
| 65 | } |
||
| 66 | |||
| 67 | public function isAtomic(): bool |
||
| 70 | 1 | } |
|
| 71 | |||
| 72 | public function getBacktrace(): ?array |
||
| 73 | { |
||
| 74 | return $this->backtrace; |
||
| 75 | } |
||
| 76 | 1 | ||
| 77 | public function getProfile(): ?array |
||
| 78 | 1 | { |
|
| 79 | return $this->profile; |
||
| 80 | } |
||
| 81 | |||
| 82 | public function getNote(): ?array |
||
| 85 | } |
||
| 86 | } |
||
| 87 |