| Total Complexity | 7 |
| Total Lines | 58 |
| Duplicated Lines | 0 % |
| Coverage | 80% |
| Changes | 3 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 5 | class JsonResponse extends Dto |
||
| 6 | { |
||
| 7 | /** |
||
| 8 | * Response message |
||
| 9 | * @var string $message |
||
| 10 | */ |
||
| 11 | public $message = 'No message'; |
||
| 12 | /** |
||
| 13 | * Response result |
||
| 14 | * @var bool $success |
||
| 15 | */ |
||
| 16 | public $success = false; |
||
| 17 | /** |
||
| 18 | * Data of response |
||
| 19 | * @var array $data |
||
| 20 | */ |
||
| 21 | public $data = null; |
||
| 22 | /** |
||
| 23 | * Number of total results |
||
| 24 | * @var int total |
||
| 25 | */ |
||
| 26 | public $total = 0; |
||
| 27 | /** |
||
| 28 | * Number of pages availables |
||
| 29 | * @var int pages |
||
| 30 | */ |
||
| 31 | public $pages = 1; |
||
| 32 | |||
| 33 | 1 | private function parseData($data) { |
|
| 34 | 1 | if ($data instanceof \Generator) { |
|
| 35 | $generatedData = []; |
||
| 36 | foreach($data as $datum) { |
||
| 37 | $generatedData[] = $datum; |
||
| 38 | } |
||
| 39 | } else { |
||
| 40 | 1 | $generatedData = $data; |
|
| 41 | } |
||
| 42 | 1 | return $generatedData; |
|
| 43 | } |
||
| 44 | |||
| 45 | /** |
||
| 46 | * JsonResponse constructor. |
||
| 47 | * @param array $data |
||
| 48 | * @param bool $result |
||
| 49 | * @param integer $total |
||
| 50 | * @param int $pages |
||
| 51 | * @param string $message |
||
| 52 | * @throws \PSFS\base\exception\GeneratorException |
||
| 53 | */ |
||
| 54 | 1 | public function __construct($data = [], $result = false, $total = null, $pages = 1, $message = null) |
|
| 63 | } |
||
| 64 | } |
||
| 66 |