| Conditions | 7 |
| Paths | 8 |
| Total Lines | 40 |
| 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 = ''; $value = ''; |
||
| 40 | |||
| 41 | # Extract post array |
||
| 42 | |||
| 43 | extract($post); |
||
| 44 | |||
| 45 | # Validate name |
||
| 46 | |||
| 47 | if (false === ($name = Validate::templateComponentName($name))) return ['name', 'VARIABLE_ERROR_NAME_INVALID']; |
||
| 48 | |||
| 49 | # Check name reserved |
||
| 50 | |||
| 51 | if (false !== Template::getGlobal($name)) return ['name', 'VARIABLE_ERROR_NAME_RESERVED']; |
||
| 52 | |||
| 53 | # Check name exists |
||
| 54 | |||
| 55 | if (false === ($check_name = $this->variable->check($name, 'name'))) return 'VARIABLE_ERROR_MODIFY'; |
||
| 56 | |||
| 57 | if ($check_name === 1) return ['name', 'VARIABLE_ERROR_NAME_DUPLICATE']; |
||
| 58 | |||
| 59 | # Modify variable |
||
| 60 | |||
| 61 | $data = []; |
||
| 62 | |||
| 63 | $data['title'] = $title; |
||
| 64 | $data['name'] = $name; |
||
| 65 | $data['value'] = $value; |
||
| 66 | |||
| 67 | $modifier = ((0 === $this->variable->id) ? 'create' : 'edit'); |
||
|
|
|||
| 68 | |||
| 69 | if (!$this->variable->$modifier($data)) return 'VARIABLE_ERROR_MODIFY'; |
||
| 70 | |||
| 71 | # ------------------------ |
||
| 72 | |||
| 73 | return true; |
||
| 74 | } |
||
| 75 | } |
||
| 77 |
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.