| Conditions | 5 |
| Paths | 6 |
| Total Lines | 46 |
| Code Lines | 22 |
| Lines | 0 |
| Ratio | 0 % |
| 1 | <?php |
||
| 20 | public function __invoke(array $post) { |
||
| 21 | |||
| 22 | # Declare variables |
||
| 23 | |||
| 24 | $parent_id = ''; $title = ''; $name = ''; $visibility = ''; $access = ''; |
||
| 25 | |||
| 26 | $description = ''; $keywords = ''; $robots_index = ''; $robots_follow = ''; $contents = ''; |
||
| 27 | |||
| 28 | # Extract post array |
||
| 29 | |||
| 30 | extract($post); |
||
| 31 | |||
| 32 | # Get hash |
||
| 33 | |||
| 34 | $hash = Arr::encode([$name, Entitizer::get(ENTITY_TYPE_PAGE, $parent_id)->id]); |
||
| 35 | |||
| 36 | # Check name exists |
||
| 37 | |||
| 38 | if (false === ($check_name = $this->page->check('hash', $hash))) return 'PAGE_ERROR_MODIFY'; |
||
| 39 | |||
| 40 | if ($check_name === 1) return 'PAGE_ERROR_NAME_DUPLICATE'; |
||
| 41 | |||
| 42 | # Modify page |
||
| 43 | |||
| 44 | $data = []; |
||
| 45 | |||
| 46 | $data['parent_id'] = $parent_id; |
||
| 47 | $data['title'] = $title; |
||
| 48 | $data['name'] = $name; |
||
| 49 | $data['visibility'] = $visibility; |
||
| 50 | $data['access'] = $access; |
||
| 51 | $data['description'] = $description; |
||
| 52 | $data['keywords'] = $keywords; |
||
| 53 | $data['robots_index'] = $robots_index; |
||
| 54 | $data['robots_follow'] = $robots_follow; |
||
| 55 | $data['contents'] = $contents; |
||
| 56 | $data['hash'] = $hash; |
||
| 57 | |||
| 58 | $modifier = ((0 === $this->page->id) ? 'create' : 'edit'); |
||
|
|
|||
| 59 | |||
| 60 | if (!$this->page->$modifier($data)) return 'PAGE_ERROR_MODIFY'; |
||
| 61 | |||
| 62 | # ------------------------ |
||
| 63 | |||
| 64 | return true; |
||
| 65 | } |
||
| 66 | } |
||
| 68 |
Since your code implements the magic setter
_set, this function will be called for any write access on an undefined variable. You can add the@propertyannotation to your class or interface to document the existence of this variable.Since the property has write access only, you can use the @property-write 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.