| Conditions | 8 |
| Paths | 14 |
| Total Lines | 43 |
| Code Lines | 27 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 10 | public function serializeData($type, $array) |
||
| 11 | { |
||
| 12 | if($this->supportsType($type) === false) |
||
| 13 | { |
||
| 14 | return null; |
||
| 15 | } |
||
| 16 | if(count($array) === 0) |
||
| 17 | { |
||
| 18 | return null; |
||
| 19 | } |
||
| 20 | $data = $this->getArray($array); |
||
| 21 | $ssheat = new \PHPExcel(); |
||
| 22 | $sheat = $ssheat->setActiveSheetIndex(0); |
||
| 23 | $keys = array_shift($data); |
||
| 24 | $rowCount = count($data); |
||
| 25 | $colCount = count($keys); |
||
| 26 | for($i = 0; $i < $colCount; $i++) |
||
| 27 | { |
||
| 28 | $sheat->setCellValueByColumnAndRow($i, 1, $keys[$i]); |
||
| 29 | } |
||
| 30 | for($i = 0; $i < $rowCount; $i++) |
||
| 31 | { |
||
| 32 | for($j = 0; $j < $colCount; $j++) |
||
| 33 | { |
||
| 34 | $colName = $keys[$j]; |
||
|
|
|||
| 35 | $sheat->setCellValueByColumnAndRow($j, 2+$i, $data[$i][$j]); |
||
| 36 | } |
||
| 37 | } |
||
| 38 | if(strcasecmp($type, 'xlsx') === 0 || strcasecmp($type, 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet') === 0) |
||
| 39 | { |
||
| 40 | $writer = \PHPExcel_IOFactory::createWriter($ssheat, 'Excel2007'); |
||
| 41 | ob_start(); |
||
| 42 | $writer->save('php://output'); |
||
| 43 | return ob_get_clean(); |
||
| 44 | } |
||
| 45 | else |
||
| 46 | { |
||
| 47 | $writer = \PHPExcel_IOFactory::createWriter($ssheat, 'Excel5'); |
||
| 48 | ob_start(); |
||
| 49 | $writer->save('php://output'); |
||
| 50 | return ob_get_clean(); |
||
| 51 | } |
||
| 52 | } |
||
| 53 | } |
||
| 55 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.