| Conditions | 7 |
| Paths | 6 |
| Total Lines | 30 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 35 | public function __invoke(array $post) { |
||
| 36 | |||
| 37 | # Declare variables |
||
| 38 | |||
| 39 | $name = ''; |
||
| 40 | |||
| 41 | # Extract post array |
||
| 42 | |||
| 43 | extract($post); |
||
| 44 | |||
| 45 | # Validate name |
||
| 46 | |||
| 47 | if (false === ($name = Validate::fileName($name))) return ['name', 'FILEMANAGER_ERROR_NAME_INVALID']; |
||
| 48 | |||
| 49 | if ($this->parent->isIgnoreHidden() && preg_match('/^\./', $name)) return ['name', 'FILEMANAGER_ERROR_HIDDEN']; |
||
| 50 | |||
| 51 | # Check if name is used |
||
| 52 | |||
| 53 | if (!$this->entity->check($name)) return ['name', 'FILEMANAGER_ERROR_EXISTS']; |
||
| 54 | |||
| 55 | # Rename entity |
||
| 56 | |||
| 57 | if (!$this->entity->rename($name)) return (($this->entity->getType() === 'dir') ? |
||
| 58 | |||
| 59 | 'FILEMANAGER_ERROR_DIR_RENAME' : 'FILEMANAGER_ERROR_FILE_RENAME'); |
||
| 60 | |||
| 61 | # ------------------------ |
||
| 62 | |||
| 63 | return true; |
||
| 64 | } |
||
| 65 | } |
||
| 67 |