protected function create($step)
    {
        foreach (array('object_state_group', 'names', 'identifier') as $key) {
            if (!isset($step->dsl[$key])) {
                throw new \Exception("The '$key' key is missing in a object state creation definition");
            }
        }

        if (!count($step->dsl['names'])) {
            throw new \Exception('No object state names have been defined. Need to specify at least one to create the state.');
        }

        $objectStateService = $this->repository->getObjectStateService();

        $objectStateGroupId = $step->dsl['object_state_group'];
        $objectStateGroupId = $this->referenceResolver->resolveReference($objectStateGroupId);
        $objectStateGroup = $this->objectStateGroupMatcher->matchOneByKey($objectStateGroupId);

        $objectStateIdentifier = $this->referenceResolver->resolveReference($step->dsl['identifier']);
        $objectStateCreateStruct = $objectStateService->newObjectStateCreateStruct($objectStateIdentifier);
        $objectStateCreateStruct->defaultLanguageCode = $this->getLanguageCode($step); // was: self::DEFAULT_LANGUAGE_CODE;

        foreach ($step->dsl['names'] as $languageCode => $name) {
            $objectStateCreateStruct->names[$languageCode] = $name;
        }
        if (isset($step->dsl['descriptions'])) {
            foreach ($step->dsl['descriptions'] as $languageCode => $description) {
                $objectStateCreateStruct->descriptions[$languageCode] = $description;
            }
        }

        $objectState = $objectStateService->createObjectState($objectStateGroup, $objectStateCreateStruct);

        $this->setReferences($objectState, $step);

        return $objectState;
    }