/** * Create a new directory for file uploads * * @param int $directoryId * @param string $cabin * @param array $post * @return array */ protected function createDir($directoryId = null, string $cabin = '', array $post = []) : array { if (!\array_key_exists('directory', $post)) { return ['status' => 'ERROR', 'message' => 'Directory names cannot be empty']; } if (!$this->files->isValidName($post['directory'])) { return ['status' => 'ERROR', 'message' => 'Invalid directory name']; } if ($this->files->dirExists($directoryId, $cabin, $post['directory'])) { return ['status' => 'ERROR', 'message' => 'This directory already exists']; } if ($this->files->createDirectory($directoryId, $cabin, $post['directory'])) { return ['status' => 'SUCCESS', 'message' => 'This directory has been created sucessfully']; } return ['status' => 'UNKNOWN', 'message' => 'An unknown error has occurred.']; }