public function fake(EntityInterface $entity, array $options = array())
    {
        if (!empty($options[self::OPTION_LOCALE])) {
            $loc = $options[self::OPTION_LOCALE];
            if (!is_string($loc) || !preg_match('#[a-z]{2,6}_[A-Z]{2,6}#', $loc)) {
                throw new BadValueException(
                    'Given option "' . self::OPTION_LOCALE
                    . '" is not a valid string. Use "languageCode_countryCode", e.g. "de_DE" or "en_UK".'
                );
            }
            $this->locale = $loc;
            $this->faker = Factory::create($this->locale);
        }

        $attributes_to_exclude = array();
        if (!empty($options[self::OPTION_EXCLUDED_FIELDS])) {
            $excluded = $options[self::OPTION_EXCLUDED_FIELDS];
            if (!is_array($excluded)) {
                throw new BadValueException(
                    'Given option "' . self::OPTION_EXCLUDED_FIELDS
                    . '" is not an array. It should be an array of attribute_names.'
                );
            }
            $attributes_to_exclude = $excluded;
        }

        $type = $entity->getType();
        foreach ($type->getAttributes() as $attribute_name => $attribute) {
            if (in_array($attribute_name, $attributes_to_exclude, true)) {
                continue;
            }

            $name = $this->getMethodNameFor($attribute);
            if (null !== $name) {
                $this->$name($entity, $attribute, $options);
            } else {
                $this->setValue($entity, $attribute, $attribute->getDefaultValue(), $options);
            }
        }

        if (array_key_exists(self::OPTION_MARK_CLEAN, $options)
            && true === $options[self::OPTION_MARK_CLEAN]
        ) {
            $entity->markClean();
        }
    }