| Conditions | 6 |
| Paths | 7 |
| Total Lines | 37 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 35 | public function __invoke(array $post) { |
||
| 36 | |||
| 37 | # Declare variables |
||
| 38 | |||
| 39 | $title = ''; $name = ''; $active = ''; $contents = ''; |
||
| 40 | |||
| 41 | # Extract post array |
||
| 42 | |||
| 43 | extract($post); |
||
| 44 | |||
| 45 | # Validate name |
||
| 46 | |||
| 47 | if (false === ($name = Validate::templateComponentName($name))) return ['name', 'WIDGET_ERROR_NAME_INVALID']; |
||
| 48 | |||
| 49 | # Check name exists |
||
| 50 | |||
| 51 | if (false === ($check_name = $this->widget->check($name, 'name'))) return 'WIDGET_ERROR_MODIFY'; |
||
| 52 | |||
| 53 | if ($check_name === 1) return ['name', 'WIDGET_ERROR_NAME_DUPLICATE']; |
||
| 54 | |||
| 55 | # Modify widget |
||
| 56 | |||
| 57 | $data = []; |
||
| 58 | |||
| 59 | $data['title'] = $title; |
||
| 60 | $data['name'] = $name; |
||
| 61 | $data['active'] = $active; |
||
| 62 | $data['contents'] = $contents; |
||
| 63 | |||
| 64 | $modifier = ((0 === $this->widget->id) ? 'create' : 'edit'); |
||
|
|
|||
| 65 | |||
| 66 | if (!$this->widget->$modifier($data)) return 'WIDGET_ERROR_MODIFY'; |
||
| 67 | |||
| 68 | # ------------------------ |
||
| 69 | |||
| 70 | return true; |
||
| 71 | } |
||
| 72 | } |
||
| 74 |
Since your code implements the magic getter
_get, this function will be called for any read access on an undefined variable. You can add the@propertyannotation to your class or interface to document the existence of this variable.If the property has read access only, you can use the @property-read annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.