| Conditions | 3 |
| Paths | 3 |
| Total Lines | 18 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 12 |
| CRAP Score | 3 |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 27 | 16 | public static function fromArray($array = array()) { |
|
| 28 | 16 | $required = array('name','date','path','items'); |
|
| 29 | 16 | $report = new Report(); |
|
| 30 | |||
| 31 | /** |
||
| 32 | * Check if all required fields are being set. |
||
| 33 | */ |
||
| 34 | 16 | foreach ($required as $req) { |
|
| 35 | 16 | if (isset($array[$req]) === false) { |
|
| 36 | 10 | throw new Exception\RuntimeException('Could not create a report from this array field ' . $req . ' was not set the following fields are required (' . implode(',', $required) . ')'); |
|
| 37 | } |
||
| 38 | 6 | } |
|
| 39 | 12 | $report->setName($array['name']); |
|
| 40 | 12 | $report->setDate($array['date']); |
|
| 41 | 12 | $report->setPath($array['path']); |
|
| 42 | 12 | $report->setItems($array['items']); |
|
| 43 | 12 | return $report; |
|
| 44 | } |
||
| 45 | |||
| 46 | } |