Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
n/a
0 / 0
n/a
0 / 0
CRAP
n/a
0 / 0
1<?php
2
3#declare(strict_types=1);
4
5/**
6 * CNIC
7 * Copyright © CentralNic Group PLC
8 */
9
10namespace CNIC;
11
12/**
13 * Common Response Interface
14 *
15 * @package CNIC
16 */
17interface ResponseInterface
18{
19    /**
20     * Constructor
21     * @param string $raw API plain response
22     * @param array $cmd API command used within this request
23     * @param array $ph placeholder array to get vars in response description dynamically replaced
24     */
25    public function __construct(string $raw, array $cmd, array $ph = []);
26
27    /**
28     * Get API response code
29     * @return integer API response code
30     */
31    public function getCode(): int;
32
33    /**
34     * Get API response description
35     * @return string API response description
36     */
37    public function getDescription(): string;
38
39    /**
40     * Get Plain API response
41     * @return string Plain API response
42     */
43    public function getPlain(): string;
44
45    /**
46     * Get Queuetime of API response
47     * @return float Queuetime of API response
48     */
49    public function getQueuetime(): float;
50
51    /**
52     * Get API response as Hash
53     * @return array API response hash
54     */
55    public function getHash(): array;
56
57    /**
58     * Get Runtime of API response
59     * @return float Runtime of API response
60     */
61    public function getRuntime(): float;
62
63    /**
64     * Check if current API response represents an error case
65     * API response code is an 5xx code
66     * @return bool boolean result
67     */
68    public function isError(): bool;
69
70    /**
71     * Check if current API response represents a success case
72     * API response code is an 2xx code
73     * @return bool boolean result
74     */
75    public function isSuccess(): bool;
76
77    /**
78     * Check if current API response represents a temporary error case
79     * API response code is an 4xx code
80     * @return bool result
81     */
82    public function isTmpError(): bool;
83
84    /**
85     * Check if current operation is returned as pending
86     * @return bool result
87     */
88    public function isPending(): bool;
89
90    /**
91     * Add a column to the column list
92     * @param string $key column name
93     * @param string[] $data array of column data
94     * @return ResponseInterface
95     */
96    public function addColumn($key, $data): ResponseInterface;
97
98    /**
99     * Add a record to the record list
100     * @param array $h row hash data
101     * @return ResponseInterface
102     */
103    public function addRecord($h): ResponseInterface;
104
105    /**
106     * Get column by column name
107     * @param string $key column name
108     * @return ColumnInterface|null column instance or null if column does not exist
109     */
110    public function getColumn($key): ?ColumnInterface;
111
112    /**
113     * Get Data by Column Name and Index
114     * @param string $colkey column name
115     * @param integer $index column data index
116     * @return string|null column data at index or null if not found
117     */
118    public function getColumnIndex($colkey, $index): ?string;
119
120    /**
121     * Get Column Names
122     * @return string[] Array of Column Names
123     */
124    public function getColumnKeys(): array;
125
126    /**
127     * Get List of Columns
128     * @return ColumnInterface[] Array of Columns
129     */
130    public function getColumns();
131
132    /**
133     * Get Command used in this request
134     * @return array command
135     */
136    public function getCommand(): array;
137
138    /**
139     * Get Command used in this request in plain text format
140     * @return string command
141     */
142    public function getCommandPlain(): string;
143
144    /**
145     * Get Page Number of current List Query
146     * @return integer|null page number or null in case of a non-list response
147     */
148    public function getCurrentPageNumber(): ?int;
149
150    /**
151     * Get Record of current record index
152     * @return RecordInterface|null Record or null in case of a non-list rfunction getCurrentRecordesponse
153     */
154    public function getCurrentRecord(): ?RecordInterface;
155
156    /**
157     * Get Index of first row in this response
158     * @return integer|null first row index
159     */
160    public function getFirstRecordIndex(): ?int;
161
162    /**
163     * Get last record index of the current list query
164     * @return integer|null record index or null for a non-list response
165     */
166    public function getLastRecordIndex(): ?int;
167
168    /**
169     * Get Response as List Hash including useful meta data for tables
170     * @return array hash including list meta data and array of rows in hash notation
171     */
172    public function getListHash(): array;
173
174    /**
175     * Get next record in record list
176     * @return RecordInterface|null Record or null in case there's no further record
177     */
178    public function getNextRecord(): ?RecordInterface;
179
180    /**
181     * Get Page Number of next list query
182     * @return integer|null page number or null if there's no next page
183     */
184    public function getNextPageNumber(): ?int;
185
186    /**
187     * Get the number of pages available for this list query
188     * @return integer number of pages
189     */
190    public function getNumberOfPages(): int;
191
192    /**
193     * Get object containing all paging data
194     * @return array paginator data
195     */
196    public function getPagination(): array;
197
198    /**
199     * Get Page Number of previous list query
200     * @return integer|null page number or null if there's no previous page
201     */
202    public function getPreviousPageNumber(): ?int;
203
204    /**
205     * Get previous record in record list
206     * @return RecordInterface|null Record or null if there's no previous record
207     */
208    public function getPreviousRecord(): ?RecordInterface;
209
210    /**
211     * Get Record at given index
212     * @param integer $idx record index
213     * @return RecordInterface|null Record or null if index does not exist
214     */
215    public function getRecord($idx): ?RecordInterface;
216
217    /**
218     * Get all Records
219     * @return RecordInterface[] array of records
220     */
221    public function getRecords();
222
223    /**
224     * Get count of rows in this response
225     * @return integer count of rows
226     */
227    public function getRecordsCount(): int;
228
229    /**
230     * Get total count of records available for the list query
231     * @return integer total count of records or count of records for a non-list response
232     */
233    public function getRecordsTotalCount(): int;
234
235    /**
236     * Get limit(ation) setting of the current list query
237     * This is the count of requested rows
238     * @return integer limit setting or count requested rows
239     */
240    public function getRecordsLimitation(): int;
241
242    /**
243     * Check if this list query has a next page
244     * @return bool boolean result
245     */
246    public function hasNextPage(): bool;
247
248    /**
249     * Check if this list query has a previous page
250     * @return bool boolean result
251     */
252    public function hasPreviousPage(): bool;
253
254    /**
255     * Reset index in record list back to zero
256     * @return ResponseInterface
257     */
258    public function rewindRecordList(): ResponseInterface;
259
260    /**
261     * Check if column exists in response
262     * @param string $key column name
263     * @return bool boolean result
264     */
265    //private function hasColumn($key): bool;
266
267    /**
268     * Check if the record list contains a record for the
269     * current record index in use
270     * @return bool boolean result
271     */
272    //private function hasCurrentRecord(): bool;
273
274    /**
275     * Check if the record list contains a next record for the
276     * current record index in use
277     * @return bool boolean result
278     */
279    //private function hasNextRecord(): bool;
280
281    /**
282     * Check if the record list contains a previous record for the
283     * current record index in use
284     * @return bool boolean result
285     */
286    //private function hasPreviousRecord(): bool;
287}