<commit_before><?php

namespace Zepto\Flysystem\Plugin;

/**
 * DateParser
 *
 * @package    Zepto
 * @subpackage Flysystem
 * @author     <NAME> <<EMAIL>>
 * @link       https://github.com/hassankhan/Zepto
 * @license    MIT
 * @since      0.7
 */
class DateParser implements \League\Flysystem\PluginInterface
{

    /**
     * Filesystem object
     *
     * @var \League\Flysystem\FilesystemInterface
     */
    protected $filesystem;

    /**
     * Array of content paths as keys and their dates as values
     *
     * @var array
     */
    protected $date_list;

    /**
     * Sets the filesystem for this plugin
     *
     * @param LeagueFlysystemFilesystemInterface $filesystem
     * @codeCoverageIgnore
     */
    public function setFilesystem(\League\Flysystem\FilesystemInterface $filesystem)
    {
        $this->filesystem = $filesystem;
    }

    /**
     * Returns plugin's method name
     *
     * @return string
     */
    public function getMethod()
    {
        return 'dates';
    }

    /**
     * Plugin handler
     *
     * @param  string $path
     * @return array
     */
    public function handle($path = '')
    {
        // Get all files in path
        $contents = $this->filesystem->listContents($path, TRUE);
        $this->date_list = array();

        // Create empty variable
        $this->oldest_date = '';

        // Iterate through files and get dates
        foreach ($contents as $file) {
            if (
                isset($file['extension']) === TRUE
                && $file['extension'] === 'md'
            ) {
                $file_contents = $this->filesystem->parse($file['path']);
                $date = new \DateTime($file_contents['meta']['date']);
                $this->date_list[$file['path']] = $date;
            }
        }

        // Sort the files by date
        uasort($this->date_list, function ($a, $b) {
            if ($a === $b) {
                return 0;
            }
            return ($a > $b) ? -1 : 1;
        });

        return $this->date_list;
    }

}<commit_msg>Cleaned up ``Zepto\Flysystem\Plugin\DateParser``<commit_after><?php

namespace Zepto\Flysystem\Plugin;

/**
 * DateParser
 *
 * @package    Zepto
 * @subpackage Flysystem
 * @author     <NAME> <<EMAIL>>
 * @link       https://github.com/hassankhan/Zepto
 * @license    MIT
 * @since      0.7
 */
class DateParser implements \League\Flysystem\PluginInterface
{

    /**
     * Filesystem object
     *
     * @var \League\Flysystem\FilesystemInterface
     */
    protected $filesystem;

    /**
     * Array of content paths as keys and their dates as values
     *
     * @var array
     */
    protected $date_list;

    /**
     * Sets the filesystem for this plugin
     *
     * @param LeagueFlysystemFilesystemInterface $filesystem
     * @codeCoverageIgnore
     */
    public function setFilesystem(\League\Flysystem\FilesystemInterface $filesystem)
    {
        $this->filesystem = $filesystem;
    }

    /**
     * Returns plugin's method name
     *
     * @return string
     */
    public function getMethod()
    {
        return 'dates';
    }

    /**
     * Plugin handler
     *
     * @param  string $path
     * @return array
     */
    public function handle($path = '')
    {
        // Get all files in path
        $contents = $this->filesystem->listContents($path, TRUE);
        // Create array
        $this->date_list = array();

        // Iterate through files and get dates
        foreach ($contents as $file) {
            if (
                isset($file['extension']) === TRUE
                && $file['extension'] === 'md'
            ) {
                $this->date_list[$file['path']] = $this->get_date($file);
            }
        }

        // Sort the files by date
        uasort($this->date_list, function ($a, $b) {
            if ($a === $b) {
                return 0;
            }
            return ($a > $b) ? -1 : 1;
        });

        return $this->date_list;
    }

    public function get_date($file)
    {
        $file_contents = $this->filesystem->parse($file['path']);
        if (isset($file_contents['meta']['date']) === FALSE) {
            return NULL;
        }
        return new \DateTime($file_contents['meta']['date']);
    }

}
{'fraction_non_alphanumeric': 0.13722730471498945, 'fraction_numerical': 0.002345765892563922, 'mean_word_length': 1.761658031088083, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 31, 'https://': 2, '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': '1360661', 'n_tokens_mistral': 1273, 'n_tokens_neox': 1213, 'n_words': 280}