Issues (52)

src/Responses/TaskResponse.php (1 issue)

Severity
1
<?php
2
declare(strict_types=1);
3
4
namespace Level23\Druid\Responses;
5
6
class TaskResponse extends QueryResponse
7
{
8
    /**
9
     * @var array<string,array<string,string|int>>
10
     */
11
    protected array $response;
12
13
    /**
14
     * We will return an array like this:
15
     *
16
     * [
17
     *    [id] => index_traffic-conversions-TEST2_2019-03-18T16:26:05.186Z
18
     *    [type] => index
19
     *    [createdTime] => 2019-03-18T16:26:05.202Z
20
     *    [queueInsertionTime] => 1970-01-01T00:00:00.000Z
21
     *    [statusCode] => SUCCESS
22
     *    [status] => SUCCESS
23
     *    [runnerStatusCode] => WAITING
24
     *    [duration] => 10255
25
     *    [location] => Array
26
     *        (
27
     *            [host] =>
28
     *            [port] => -1
29
     *            [tlsPort] => -1
30
     *        )
31
     *
32
     *
33
     *    [dataSource] => traffic-conversions-TEST2
34
     *    [errorMsg] =>
35
     * ]
36
     *
37
     * or an empty array when no status was found.
38
     *
39
     * @return array<string,string|int|array<mixed>>
40
     */
41 2
    public function data(): array
42
    {
43
        /** @var array<string,string|int|array<mixed>> $data */
44 2
        $data = $this->response['status'] ?? [];
45
46 2
        return $data;
0 ignored issues
show
The expression return $data returns an array which contains values of type integer|string which are incompatible with the return type array<mixed,mixed> mandated by Level23\Druid\Responses\QueryResponse::data().
Loading history...
47
    }
48
49
    /**
50
     * Return the task id or an empty string when not known
51
     *
52
     * @return string
53
     */
54 3
    public function getId(): string
55
    {
56 3
        if (isset($this->response['status']['id'])) {
57 2
            return (string)$this->response['status']['id'];
58
        }
59
60 1
        return '';
61
    }
62
63
    /**
64
     * Return the status code or an empty string when not known.
65
     *
66
     * @return string
67
     */
68 2
    public function getStatusCode(): string
69
    {
70 2
        if (isset($this->response['status']['statusCode'])) {
71 1
            return (string)$this->response['status']['statusCode'];
72
        }
73
74 1
        return '';
75
    }
76
77
    /**
78
     * Return the status or an empty string when not known.
79
     *
80
     * @return string
81
     */
82 3
    public function getStatus(): string
83
    {
84 3
        if (isset($this->response['status']['status'])) {
85 2
            return (string)$this->response['status']['status'];
86
        }
87
88 1
        return '';
89
    }
90
91
    /**
92
     * Return the error message or an empty string when not known.
93
     *
94
     * @return string
95
     */
96 2
    public function getErrorMsg(): string
97
    {
98 2
        if (isset($this->response['status']['errorMsg'])) {
99 1
            return (string)$this->response['status']['errorMsg'];
100
        }
101
102 1
        return '';
103
    }
104
}