private function getTempDir($directory)
    {
        if (empty($directory) || !is_string($directory)) {
            $classParts = explode("\\", get_called_class());
            return sys_get_temp_dir()  . '/' . end($classParts);
        } elseif (strpos($directory, '/') !== 0) {
            return sys_get_temp_dir() . '/' . $directory;
        } else {
            return $directory;
        }
    }