<commit_before><?php


namespace Brera\Context;

use Brera\Http\HttpRequest;

class WebsiteContextDecorator extends ContextDecorator
{
    const CODE = 'website';
    
    private $defaultWebsite = 'ru';
    
    private $validWebsites = [
        'ru',
        'cy'
    ];

    /**
     * @return string
     */
    protected function getCode()
    {
        return self::CODE;
    }

    /**
     * @return string
     */
    protected function getValueFromContext()
    {
        if ($this->isWebsiteCodeinSourceData()) {
            return $this->getWebsiteValueFromSourceData();
        }
        if ($this->isRequestInSourceData()) {
            return $this->getWebsiteFromRequest();
        }
        throw new UnableToDetermineWebsiteContextException(sprintf(
            'Unable to determine website from context source data ("%s" and "request" not present)',
            self::CODE
        ));
    }

    /**
     * @return HttpRequest
     */
    private function getRequest()
    {
        return $this->getSourceData()['request'];
    }

    /**
     * @return bool
     */
    private function isWebsiteCodeinSourceData()<commit_msg>Issue #309: Fix capitalization in method name<commit_after><?php


namespace Brera\Context;

use Brera\Http\HttpRequest;

class WebsiteContextDecorator extends ContextDecorator
{
    const CODE = 'website';
    
    private $defaultWebsite = 'ru';
    
    private $validWebsites = [
        'ru',
        'cy'
    ];

    /**
     * @return string
     */
    protected function getCode()
    {
        return self::CODE;
    }

    /**
     * @return string
     */
    protected function getValueFromContext()
    {
        if ($this->isWebsiteCodeInSourceData()) {
            return $this->getWebsiteValueFromSourceData();
        }
        if ($this->isRequestInSourceData()) {
            return $this->getWebsiteFromRequest();
        }
        throw new UnableToDetermineWebsiteContextException(sprintf(
            'Unable to determine website from context source data ("%s" and "request" not present)',
            self::CODE
        ));
    }

    /**
     * @return HttpRequest
     */
    private function getRequest()
    {
        return $this->getSourceData()['request'];
    }

    /**
     * @return bool
     */
    private function isWebsiteCodeInSourceData()
{'fraction_non_alphanumeric': 0.11426116838487972, 'fraction_numerical': 0.001288659793814433, 'mean_word_length': 2.1178045515394914, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, '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': '1444661', 'n_tokens_mistral': 661, 'n_tokens_neox': 631, 'n_words': 141}