<commit_before><?php
/*
 * This file is part of the feed-io package.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
 
namespace FeedIo;

use \FeedIo\Reader;
use \FeedIo\Reader\FixerSet;
use \FeedIo\Reader\FixerInterface;
use \FeedIo\Rule\DateTimeBuilder;
use \FeedIo\Adapter\ClientInterface;
use FeedIo\Standard\Atom;
use FeedIo\Standard\Rss;
use \Psr\Log\LoggerInterface;

class FeedIo
{

    /**
     * @var \FeedIo\Reader
     */
    protected $reader;
    
    /**
     * @var \FeedIo\Rule\DateTimeBuilder
     */
    protected $dateTimeBuilder;
    
    /**
     * @var \Psr\Log\LoggerInterface
     */
    protected $logger;
    
    /**
     * @var array
     */
    protected $standards;

    /**
     * @var \FeedIo\Reader\FixerSet
     */
    protected $fixerSet;

    /**
     * @param \FeedIo\Adapter\ClientInterface $client
     * @param \Psr\Log\LoggerInterface $logger
     */
    public function __construct(ClientInterface $client, LoggerInterface $logger)
    {
        $this->logger = $logger;
        $this->dateTimeBuilder = new DateTimeBuilder;
        $this->setReader(new Reader($client, $logger));
        $this->loadCommonStandards();
        $this->loadFixerSet();
    }
    
    /**
     * @return $this
     */
    protected function loadCommonStandards()
    {
        $standards = $this->getCommonStandards();
        foreach ($standards as $name => $standard) {
            $this->addStandard($name, $standard);
        }
        
        return $this;
    }
    
    /**
     * @return array
     */
    public function getCommonStandards()
    {
        return array(
            'atom' => new Atom($this->dateTimeBuilder),
            'rss' => new Rss($this->dateTimeBuilder),
        );
    }
     
    /**
     * @param string $name
     * @param \FeedIo\StandardAbstract $standard
     * @return $this
     */
    public function addStandard($name, StandardAbstract $standard)
    {
        $name = strtolower($name);
        $this->standards[$name] = $standard;
        $this->reader->addParser(
                            new Parser($standard, $this->logger)
                        );
        
        return $this;
    }
    
    /**
     * @return $this;
     */   
    protected function loadFixerSet()
    {
        $this->fixerSet = new FixerSet;
        $fixers = $this->getBaseFixers();
        
        foreach ( $fixers as $fixer ) {
            $this->addFixer($fixer);
        }
        
        return $this;
    }

    /**
     * 
     */
    public function addFixer(FixerInterface $fixer)
    {
        $fixer->setLogger($this->logger);
        $this->fixerSet->add($fixer);
        
        return $this;
    }
    
    /**
     *
     */
    public function getBaseFixers()
    {
        return array(
            new \FeedIo\Reader\Fixer\LastModified,
        );
    }

    /**
     * @return \FeedIo\Rule\DateTimeBuilder
     */
    public function getDateTimeBuilder()
    {
        return $this->dateTimeBuilder;
    }
    
    /**
     * @return \FeedIo\Reader
     */<commit_msg>Documentation<commit_after><?php
/*
 * This file is part of the feed-io package.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
 
namespace FeedIo;

use \FeedIo\Reader;
use \FeedIo\Reader\FixerSet;
use \FeedIo\Reader\FixerInterface;
use \FeedIo\Rule\DateTimeBuilder;
use \FeedIo\Adapter\ClientInterface;
use FeedIo\Standard\Atom;
use FeedIo\Standard\Rss;
use \Psr\Log\LoggerInterface;

class FeedIo
{

    /**
     * @var \FeedIo\Reader
     */
    protected $reader;
    
    /**
     * @var \FeedIo\Rule\DateTimeBuilder
     */
    protected $dateTimeBuilder;
    
    /**
     * @var \Psr\Log\LoggerInterface
     */
    protected $logger;
    
    /**
     * @var array
     */
    protected $standards;

    /**
     * @var \FeedIo\Reader\FixerSet
     */
    protected $fixerSet;

    /**
     * @param \FeedIo\Adapter\ClientInterface $client
     * @param \Psr\Log\LoggerInterface $logger
     */
    public function __construct(ClientInterface $client, LoggerInterface $logger)
    {
        $this->logger = $logger;
        $this->dateTimeBuilder = new DateTimeBuilder;
        $this->setReader(new Reader($client, $logger));
        $this->loadCommonStandards();
        $this->loadFixerSet();
    }
    
    /**
     * @return $this
     */
    protected function loadCommonStandards()
    {
        $standards = $this->getCommonStandards();
        foreach ($standards as $name => $standard) {
            $this->addStandard($name, $standard);
        }
        
        return $this;
    }
    
    /**
     * @return array
     */
    public function getCommonStandards()
    {
        return array(
            'atom' => new Atom($this->dateTimeBuilder),
            'rss' => new Rss($this->dateTimeBuilder),
        );
    }
     
    /**
     * @param string $name
     * @param \FeedIo\StandardAbstract $standard
     * @return $this
     */
    public function addStandard($name, StandardAbstract $standard)
    {
        $name = strtolower($name);
        $this->standards[$name] = $standard;
        $this->reader->addParser(
                            new Parser($standard, $this->logger)
                        );
        
        return $this;
    }
    
    /**
     * @return $this
     */   
    protected function loadFixerSet()
    {
        $this->fixerSet = new FixerSet;
        $fixers = $this->getBaseFixers();
        
        foreach ( $fixers as $fixer ) {
            $this->addFixer($fixer);
        }
        
        return $this;
    }

    /**
     * @param FixerInterface $fixer
     * @return $this
     */
    public function addFixer(FixerInterface $fixer)
    {
        $fixer->setLogger($this->logger);
        $this->fixerSet->add($fixer);
        
        return $this;
    }

    /**
     * @return array
     */
    public function getBaseFixers()
    {
        return array(
            new Reader\Fixer\LastModified,
        );
    }

    /**
     * @return \FeedIo\Rule\DateTimeBuilder
     */
    public function getDateTimeBuilder()
    {
        return $this->dateTimeBuilder;
    }
    
    /**
     * @return \FeedIo\Reader
     */
{'fraction_non_alphanumeric': 0.13179390512095507, 'fraction_numerical': 0.0, 'mean_word_length': 1.7962231005709266, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 57, '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': '7281584', 'n_tokens_mistral': 1942, 'n_tokens_neox': 1916, 'n_words': 379}