public function deSerialize()
    {
        $legacySaveFile = sprintf('%s/%s', $this->path, static::LEGACY_SAVE_FILE);
        if (file_exists($legacySaveFile)) {
            $userState = $this->migrateData($legacySaveFile);

            if ($userState instanceof UserState) {
                return $userState;
            }
        }

        $json = $this->readJson(sprintf('%s/%s', $this->path, static::SAVE_FILE));
        if (null === $json) {
            $this->wipeFile();
            return new UserState();
        }

        if (!isset($json[$this->workshopName])) {
            return new UserState();
        }

        $json = $json[$this->workshopName];
        if (!array_key_exists('completed_exercises', $json)) {
            return new UserState();
        }

        if (!array_key_exists('current_exercise', $json)) {
            return new UserState();
        }

        if (!is_array($json['completed_exercises'])) {
            $json['completed_exercises'] = [];
        }

        foreach ($json['completed_exercises'] as $i => $exercise) {
            if (!is_string($exercise)) {
                unset($json['completed_exercises'][$i]);
            }
        }

        if (null !== $json['current_exercise'] && !is_string($json['current_exercise'])) {
            $json['current_exercise'] = null;
        }

        return new UserState(
            $json['completed_exercises'],
            $json['current_exercise']
        );
    }