<commit_before><?php

namespace Brera\Product;

use Brera\SnippetKeyGenerator;
use Brera\InvalidSnippetKeyIdentifierException;
use Brera\Environment\Environment;
use Brera\Environment\VersionedEnvironment;

class ProductDetailViewSnippetKeyGenerator implements SnippetKeyGenerator
{
    const KEY_PREFIX = 'product_detail_view';

    /**
     * @param mixed|ProductId $productId
     * @param Environment $environment
     * @throws InvalidSnippetKeyIdentifierException
     * @return string
     */
    public function getKeyForEnvironment($productId, Environment $environment)
    {
        if (!($productId instanceof ProductId)) {
            throw new InvalidSnippetKeyIdentifierException(sprintf(
                'Expected instance of ProductId, but got "%s"',
                is_scalar($productId) ? $productId : gettype($productId)
            ));
        }

        return $this->getKeyForProductIdInEnvironment($productId, $environment);
    }

    /**
     * @param ProductId $productId
     * @param Environment $environment
     * @return string
     */
    private function getKeyForProductIdInEnvironment(ProductId $productId, Environment $environment)
    {
        return sprintf('%s_%s_%s', self::KEY_PREFIX, $environment->getValue(VersionedEnvironment::CODE), $productId);
    }
}
<commit_msg>Issue #73: Call the generic method getId on environment instead only using the version<commit_after><?php

namespace Brera\Product;

use Brera\SnippetKeyGenerator;
use Brera\InvalidSnippetKeyIdentifierException;
use Brera\Environment\Environment;
use Brera\Environment\VersionedEnvironment;

class ProductDetailViewSnippetKeyGenerator implements SnippetKeyGenerator
{
    const KEY_PREFIX = 'product_detail_view';

    /**
     * @param mixed|ProductId $productId
     * @param Environment $environment
     * @throws InvalidSnippetKeyIdentifierException
     * @return string
     */
    public function getKeyForEnvironment($productId, Environment $environment)
    {
        if (!($productId instanceof ProductId)) {
            throw new InvalidSnippetKeyIdentifierException(sprintf(
                'Expected instance of ProductId, but got "%s"',
                is_scalar($productId) ? $productId : gettype($productId)
            ));
        }

        return $this->getKeyForProductIdInEnvironment($productId, $environment);
    }

    /**
     * @param ProductId $productId
     * @param Environment $environment
     * @return string
     */
    private function getKeyForProductIdInEnvironment(ProductId $productId, Environment $environment)
    {
        return sprintf('%s_%s_%s', self::KEY_PREFIX, $productId, $environment->getId());
    }
}

{'fraction_non_alphanumeric': 0.0937031484257871, 'fraction_numerical': 0.0007496251874062968, 'mean_word_length': 3.6017241379310345, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2975751', 'n_tokens_mistral': 697, 'n_tokens_neox': 693, 'n_words': 157}