<commit_before><?php namespace Rollbar;

use Rollbar\Payload\Level;
use Rollbar\Payload\Payload;

if (!defined('ROLLBAR_INCLUDED_ERRNO_BITMASK')) {
    define(
        'ROLLBAR_INCLUDED_ERRNO_BITMASK',
        E_ERROR | E_WARNING | E_PARSE | E_CORE_ERROR | E_USER_ERROR | E_RECOVERABLE_ERROR
    );
}

class Config
{
    private $accessToken;
    /**
     * @var DataBuilder
     */
    private $dataBuilder;
    private $configArray;
    /**
     * @var TransformerInterface
     */
    private $transformer;
    /**
     * @var FilterInterface
     */
    private $filter;
    private $minimumLevel;
    /**
     * @var ResponseHandlerInterface
     */
    private $responseHandler;
    /**
     * @var \Rollbar\Senders\SenderInterface
     */
    private $sender;
    private $reportSuppressed;
    /**
     * @var callable
     */
    private $checkIgnore;
    private $error_sample_rates = array();
    private $mt_randmax;

    private $included_errno = ROLLBAR_INCLUDED_ERRNO_BITMASK;
    
    /**
     * @var boolean Should debug_backtrace() data be sent with string messages
     * sent through RollbarLogger::log()
     */
    private $sendMessageTrace = false;

    public function __construct(array $configArray)
    {
        $this->updateConfig($configArray);

        if (isset($configArray['error_sample_rates'])) {
            $this->error_sample_rates = $configArray['error_sample_rates'];
        }

        $levels = array(E_WARNING, E_NOTICE, E_USER_ERROR, E_USER_WARNING,
            E_USER_NOTICE, E_STRICT, E_RECOVERABLE_ERROR);
        // PHP 5.3.0
        if (defined('E_DEPRECATED')) {
            $levels = array_merge($levels, array(E_DEPRECATED, E_USER_DEPRECATED));
        }
        $curr = 1;
        for ($i = 0, $num = count($levels); $i < $num; $i++) {
            $level = $levels[$i];
            if (!isset($this->error_sample_rates[$level])) {
                $this->error_sample_rates[$level] = $curr;
            }
        }
        $this->mt_randmax = mt_getrandmax();
    }

    public function configure($config)
    {
        $this->updateConfig($this->extend($config));
    }

    public function extend($config)
    {
        return array_replace_recursive(array(), $this->configArray, $config);
    }

    public function getConfigArray()
    {
        return $this->configArray;
    }

    protected function updateConfig($c)
    {
        $this->configArray = $c;

        $this->setAccessToken($c);
        $this->setDataBuilder($c);
        $this->setTransformer($c);
        $this->setMinimumLevel($c);
        $this->setReportSuppressed($c);
        $this->setFilters($c);
        $this->setSender($c);
        $this->setResponseHandler($c);
        $this->setCheckIgnoreFunction($c);
        $this->setSendMessageTrace($c);
        $this->setJsEnabled($c);

        if (isset($c['included_errno'])) {
            $this->included_errno = $c['included_errno'];
        }
    }

    private function setAccessToken($c)
    {
        if (isset($_ENV['ROLLBAR_ACCESS_TOKEN']) && !isset($c['access_token'])) {
            $c['access_token'] = $_ENV['ROLLBAR_ACCESS_TOKEN'];
        }
        Utilities::validateString($c['access_token'], "config['access_token']", 32, false);
        $this->accessToken = $c['access_token'];
    }

    private function setDataBuilder($c)
    {
        $exp = "Rollbar\DataBuilderInterface";
        $def = "Rollbar\DataBuilder";
        $this->setupWithOptions($c, "dataBuilder", $exp, $def, true);
    }

    private function setTransformer($c)
    {
        $expected = "Rollbar\TransformerInterface";
        $this->setupWithOptions($c, "transformer", $expected);
    }

    private function setMinimumLevel($c)<commit_msg>github-137: more isEnabled clean up<commit_after><?php namespace Rollbar;

use Rollbar\Payload\Level;
use Rollbar\Payload\Payload;

if (!defined('ROLLBAR_INCLUDED_ERRNO_BITMASK')) {
    define(
        'ROLLBAR_INCLUDED_ERRNO_BITMASK',
        E_ERROR | E_WARNING | E_PARSE | E_CORE_ERROR | E_USER_ERROR | E_RECOVERABLE_ERROR
    );
}

class Config
{
    private $accessToken;
    /**
     * @var DataBuilder
     */
    private $dataBuilder;
    private $configArray;
    /**
     * @var TransformerInterface
     */
    private $transformer;
    /**
     * @var FilterInterface
     */
    private $filter;
    private $minimumLevel;
    /**
     * @var ResponseHandlerInterface
     */
    private $responseHandler;
    /**
     * @var \Rollbar\Senders\SenderInterface
     */
    private $sender;
    private $reportSuppressed;
    /**
     * @var callable
     */
    private $checkIgnore;
    private $error_sample_rates = array();
    private $mt_randmax;

    private $included_errno = ROLLBAR_INCLUDED_ERRNO_BITMASK;
    
    /**
     * @var boolean Should debug_backtrace() data be sent with string messages
     * sent through RollbarLogger::log()
     */
    private $sendMessageTrace = false;

    public function __construct(array $configArray)
    {
        $this->updateConfig($configArray);

        if (isset($configArray['error_sample_rates'])) {
            $this->error_sample_rates = $configArray['error_sample_rates'];
        }

        $levels = array(E_WARNING, E_NOTICE, E_USER_ERROR, E_USER_WARNING,
            E_USER_NOTICE, E_STRICT, E_RECOVERABLE_ERROR);
        // PHP 5.3.0
        if (defined('E_DEPRECATED')) {
            $levels = array_merge($levels, array(E_DEPRECATED, E_USER_DEPRECATED));
        }
        $curr = 1;
        for ($i = 0, $num = count($levels); $i < $num; $i++) {
            $level = $levels[$i];
            if (!isset($this->error_sample_rates[$level])) {
                $this->error_sample_rates[$level] = $curr;
            }
        }
        $this->mt_randmax = mt_getrandmax();
    }

    public function configure($config)
    {
        $this->updateConfig($this->extend($config));
    }

    public function extend($config)
    {
        return array_replace_recursive(array(), $this->configArray, $config);
    }

    public function getConfigArray()
    {
        return $this->configArray;
    }

    protected function updateConfig($c)
    {
        $this->configArray = $c;

        $this->setAccessToken($c);
        $this->setDataBuilder($c);
        $this->setTransformer($c);
        $this->setMinimumLevel($c);
        $this->setReportSuppressed($c);
        $this->setFilters($c);
        $this->setSender($c);
        $this->setResponseHandler($c);
        $this->setCheckIgnoreFunction($c);
        $this->setSendMessageTrace($c);

        if (isset($c['included_errno'])) {
            $this->included_errno = $c['included_errno'];
        }
    }

    private function setAccessToken($c)
    {
        if (isset($_ENV['ROLLBAR_ACCESS_TOKEN']) && !isset($c['access_token'])) {
            $c['access_token'] = $_ENV['ROLLBAR_ACCESS_TOKEN'];
        }
        Utilities::validateString($c['access_token'], "config['access_token']", 32, false);
        $this->accessToken = $c['access_token'];
    }

    private function setDataBuilder($c)
    {
        $exp = "Rollbar\DataBuilderInterface";
        $def = "Rollbar\DataBuilder";
        $this->setupWithOptions($c, "dataBuilder", $exp, $def, true);
    }

    private function setTransformer($c)
    {
        $expected = "Rollbar\TransformerInterface";
        $this->setupWithOptions($c, "transformer", $expected);
    }

    private function setMinimumLevel($c)
{'fraction_non_alphanumeric': 0.14104467539479013, 'fraction_numerical': 0.0022945066810635714, 'mean_word_length': 2.579710144927536, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 52, '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': '5150652', 'n_tokens_mistral': 2358, 'n_tokens_neox': 2268, 'n_words': 384}