<commit_before><?php

/**
 * Profiler.php
 *
 * @author <NAME> <<EMAIL>>
 */
namespace Link0\Profiler;

/**
 * Profiler itself
 *
 * @package Link0\Profiler
 */
final class Profiler
{
    /**
     * @var ProfilerAdapterInterface $profilerAdapter
     */
    protected $profilerAdapter;

    /**
     * @var PersistenceService $persistenceService
     */
    protected $persistenceService;

    /**
     * @var ProfilerAdapterInterface[] $profilerAdapters
     */
    protected $preferredProfilerAdapters;

    /**
     * @param PersistenceHandlerInterface $persistenceHandler
     * @param int                         $flags
     * @param array                       $options
     */
    public function __construct(PersistenceHandlerInterface $persistenceHandler = null, $flags = null, $options = array())
    {
        if ($flags === null) {
            // Flags for XHProf and Uprofiler adding up to consume memory and cpu statistics
            // Hardcoded to value 6, because if you have either extension, the constants of the other don't exist
            $flags = 6;
        }

        if (!isset($options['ignored_functions'])) {
            $options['ignored_functions'] = array(
                'Link0\Profiler\Profiler::getProfilerAdapter',
                'Link0\Profiler\ProfilerAdapter::stop',
                'xhprof_disable',
                'Link0\Profiler\ProfilerAdapter\XhprofAdapter::stop',
                'Link0\Profiler\ProfilerAdapter\UprofilerAdapter::stop',
                'Link0\Profiler\ProfilerAdapter\NullAdapter::stop',
                'Link0\Profiler\Profiler::stop',
            );
        }

        $this->preferredProfilerAdapters = array(
            new ProfilerAdapter\UprofilerAdapter($flags, $options),
            new ProfilerAdapter\XhprofAdapter($flags, $options),
        );
        $this->profilerAdapter = $this->getPreferredProfilerAdapter();
        $this->persistenceService = new PersistenceService($persistenceHandler);
    }

    /**
     * @param  ProfilerAdapterInterface $profilerAdapter
     * @return Profiler                 $this
     */
    public function setProfilerAdapter(ProfilerAdapterInterface $profilerAdapter)
    {
        $this->profilerAdapter = $profilerAdapter;

        return $this;
    }

    /**
     * @return ProfilerAdapterInterface $profilingAdapter
     */
    public function getProfilerAdapter()
    {
        return $this->profilerAdapter;
    }

    /**
     * @return PersistenceService $persistenceService<commit_msg>Always fallback to a working adapter<commit_after><?php

/**
 * Profiler.php
 *
 * @author <NAME> <<EMAIL>>
 */
namespace Link0\Profiler;

/**
 * Profiler itself
 *
 * @package Link0\Profiler
 */
final class Profiler
{
    /**
     * @var ProfilerAdapterInterface $profilerAdapter
     */
    protected $profilerAdapter;

    /**
     * @var PersistenceService $persistenceService
     */
    protected $persistenceService;

    /**
     * @var ProfilerAdapterInterface[] $profilerAdapters
     */
    protected $preferredProfilerAdapters;

    /**
     * @param PersistenceHandlerInterface $persistenceHandler
     * @param int                         $flags
     * @param array                       $options
     */
    public function __construct(PersistenceHandlerInterface $persistenceHandler = null, $flags = null, $options = array())
    {
        if ($flags === null) {
            // Flags for XHProf and Uprofiler adding up to consume memory and cpu statistics
            // Hardcoded to value 6, because if you have either extension, the constants of the other don't exist
            $flags = 6;
        }

        if (!isset($options['ignored_functions'])) {
            $options['ignored_functions'] = array(
                'Link0\Profiler\Profiler::getProfilerAdapter',
                'Link0\Profiler\ProfilerAdapter::stop',
                'xhprof_disable',
                'Link0\Profiler\ProfilerAdapter\XhprofAdapter::stop',
                'Link0\Profiler\ProfilerAdapter\UprofilerAdapter::stop',
                'Link0\Profiler\ProfilerAdapter\NullAdapter::stop',
                'Link0\Profiler\Profiler::stop',
            );
        }

        $this->preferredProfilerAdapters = array(
            new ProfilerAdapter\UprofilerAdapter($flags, $options),
            new ProfilerAdapter\XhprofAdapter($flags, $options),
            new ProfilerAdapter\NullAdapter(),
        );
        $this->profilerAdapter = $this->getPreferredProfilerAdapter();
        $this->persistenceService = new PersistenceService($persistenceHandler);
    }

    /**
     * @param  ProfilerAdapterInterface $profilerAdapter
     * @return Profiler                 $this
     */
    public function setProfilerAdapter(ProfilerAdapterInterface $profilerAdapter)
    {
        $this->profilerAdapter = $profilerAdapter;

        return $this;
    }

    /**
     * @return ProfilerAdapterInterface $profilingAdapter
     */
    public function getProfilerAdapter()
    {
        return $this->profilerAdapter;
    }

    /**
     * @return PersistenceService $persistenceService
{'fraction_non_alphanumeric': 0.10530451866404715, 'fraction_numerical': 0.003929273084479371, 'mean_word_length': 2.316612377850163, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 21, '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': '4869131', 'n_tokens_mistral': 1370, 'n_tokens_neox': 1417, 'n_words': 268}