<commit_before><?php

/*
 * This file is part of the Yosymfony\Spress.
 *
 * (c) YoSymfony <http://github.com/yosymfony>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
 
namespace Yosymfony\Spress\ContentLocator;

use Symfony\Component\Finder\Finder;
use Symfony\Component\Finder\SplFileInfo;
use Symfony\Component\Filesystem\Filesystem;
use Yosymfony\Spress\Configuration;

/**
 * Locate the content of a site
 * 
 * @author <NAME> <<EMAIL>>
 */
class ContentLocator
{
    private $configuration;
    private $convertersExtension = [];
    
    /**
     * Constructor
     * 
     * @param Configuration $configuration Configuration manager
     */
    public function __construct(Configuration $configuration)
    {
        if(null === $configuration)
        {
            throw new \InvalidArgumentException('Configuration is null');
        }
        
        $this->configuration = $configuration;
        $this->setCurrentDir($this->getSourceDir());
        $this->createDestinationDirIfNotExists();
    }
    
    public function setConvertersExtension(array $extensions)
    {
        $this->convertersExtension = $extensions;
    }
    
    /**
     * Get the site posts
     * 
     * @return array Array of FileItem
     */
    public function getPosts()
    {
        $posts = [];
        //$markdownExt = $this->configuration->getRepository()->get('markdown_ext');

        if(0 == count($this->convertersExtension))
        {
            return $posts;
        }

        if($this->getPostsDir())
        {
            $finder = new Finder();
            $finder->in($this->getPostsDir())->files();
            $finder->name($this->fileExtToRegExpr($this->convertersExtension));
            
            foreach($finder as $file)
            {
                $posts[] = new FileItem($file, FileItem::TYPE_POST);
            }
        }
        
        return $posts;
    }
    
    /**
     * Get the site pages. Page items is the files with extension in 
     * "processable_ext" key. This method uses "include" and "exclude" keys<commit_msg>Deleted commented code<commit_after><?php

/*
 * This file is part of the Yosymfony\Spress.
 *
 * (c) YoSymfony <http://github.com/yosymfony>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
 
namespace Yosymfony\Spress\ContentLocator;

use Symfony\Component\Finder\Finder;
use Symfony\Component\Finder\SplFileInfo;
use Symfony\Component\Filesystem\Filesystem;
use Yosymfony\Spress\Configuration;

/**
 * Locate the content of a site
 * 
 * @author <NAME> <<EMAIL>>
 */
class ContentLocator
{
    private $configuration;
    private $convertersExtension = [];
    
    /**
     * Constructor
     * 
     * @param Configuration $configuration Configuration manager
     */
    public function __construct(Configuration $configuration)
    {
        if(null === $configuration)
        {
            throw new \InvalidArgumentException('Configuration is null');
        }
        
        $this->configuration = $configuration;
        $this->setCurrentDir($this->getSourceDir());
        $this->createDestinationDirIfNotExists();
    }
    
    public function setConvertersExtension(array $extensions)
    {
        $this->convertersExtension = $extensions;
    }
    
    /**
     * Get the site posts
     * 
     * @return array Array of FileItem
     */
    public function getPosts()
    {
        $posts = [];

        if(0 == count($this->convertersExtension))
        {
            return $posts;
        }

        if($this->getPostsDir())
        {
            $finder = new Finder();
            $finder->in($this->getPostsDir())->files();
            $finder->name($this->fileExtToRegExpr($this->convertersExtension));
            
            foreach($finder as $file)
            {
                $posts[] = new FileItem($file, FileItem::TYPE_POST);
            }
        }
        
        return $posts;
    }
    
    /**
     * Get the site pages. Page items is the files with extension in 
     * "processable_ext" key. This method uses "include" and "exclude" keys
{'fraction_non_alphanumeric': 0.11711711711711711, 'fraction_numerical': 0.000474158368895211, 'mean_word_length': 2.242890084550346, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 40, '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': '6267757', 'n_tokens_mistral': 1180, 'n_tokens_neox': 1158, 'n_words': 273}