protected function fetchProject($projectId, $expectedType)
    {
        $project = $this->projectStore->getById($projectId);

        if (empty($project)) {
            throw new Exception('Project does not exist: ' . $projectId);
        }

        if (is_array($expectedType)
            ? !in_array($project->getType(), $expectedType)
            : $project->getType() !== $expectedType
        ) {
            throw new Exception('Wrong project type: ' . $project->getType());
        }

        return $project;
    }