| Conditions | 8 |
| Paths | 10 |
| Total Lines | 35 |
| Code Lines | 21 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 8 | public function serializeData(&$type, $array) |
||
| 9 | { |
||
| 10 | if($this->supportsType($type) === false) |
||
| 11 | { |
||
| 12 | return null; |
||
| 13 | } |
||
| 14 | if(count($array) === 0) |
||
| 15 | { |
||
| 16 | return null; |
||
| 17 | } |
||
| 18 | $dataTable = ($type === 'json-ss-dt'); |
||
| 19 | $type = 'application/json'; |
||
| 20 | $data = $this->getArray($array); |
||
| 21 | $names = array_shift($data); |
||
| 22 | $rowCount = count($data); |
||
| 23 | for($i = 0; $i < $rowCount; $i++) |
||
| 24 | { |
||
| 25 | $row = $data[$i]; |
||
| 26 | $colCount = count($row); |
||
| 27 | for($j = 0; $j < $colCount; $j++) |
||
| 28 | { |
||
| 29 | if(isset($row[$j]) && isset($names[$j])) |
||
| 30 | { |
||
| 31 | $row[$names[$j]] = $row[$j]; |
||
| 32 | unset($row[$j]); |
||
| 33 | } |
||
| 34 | } |
||
| 35 | $data[$i] = $row; |
||
| 36 | } |
||
| 37 | if($dataTable) |
||
| 38 | { |
||
| 39 | return json_encode(array('data'=>$data)); |
||
| 40 | } |
||
| 41 | return json_encode($data); |
||
| 42 | } |
||
| 43 | } |
||
| 44 |