| Conditions | 7 |
| Paths | 12 |
| Total Lines | 27 |
| Code Lines | 19 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 20 |
| CRAP Score | 7 |
| Changes | 0 | ||
| 1 | <?php namespace PascalKleindienst\FormListGenerator\Fields; |
||
| 32 | 27 | public function create($name, array $config) |
|
| 33 | { |
||
| 34 | 27 | $type = isset($config['type']) ? strtolower($config['type']) : 'text'; |
|
| 35 | 27 | $field = null; |
|
|
|
|||
| 36 | |||
| 37 | switch ($type) { |
||
| 38 | 27 | case 'radio': |
|
| 39 | 27 | case 'checkboxlist': |
|
| 40 | 3 | $field = new RadioCheckboxList($name, $config); |
|
| 41 | 3 | break; |
|
| 42 | 24 | case 'section': |
|
| 43 | 24 | case 'partial': |
|
| 44 | 3 | $field = new PartialHTMLField($name, $config); |
|
| 45 | 3 | break; |
|
| 46 | 21 | default: |
|
| 47 | 21 | $field = new Field($name, $config); |
|
| 48 | |||
| 49 | // Custom Field |
||
| 50 | 21 | if (array_key_exists($type, $this->customFields)) { |
|
| 51 | 3 | $class = $this->customFields[$type]; |
|
| 52 | 3 | $field = new $class($name, $config); |
|
| 53 | 3 | } |
|
| 54 | 21 | } |
|
| 55 | |||
| 56 | 27 | $field->setup(); |
|
| 57 | 27 | return $field; |
|
| 58 | } |
||
| 59 | } |
||
| 60 |
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.