<commit_before><?php

namespace Lechimp\Flightcontrol;

/**
 * Some object on the filesystem.
 */
abstract class FSObject {
    /**
     * @var Flightcontrol 
     */
    protected $flightcontrol;

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

    /**
     * @var string
     */
    protected $path;

    /**
     * @param   \Lechimp\Flightcontrol\Flightcontrol    $flightcontrol
     * @param   \League\Flysystem\Filesytem             $filesystem
     * @param   string  $path
     */
    public function __construct(Flightcontrol $flightcontrol, \League\Flysystem\Filesystem $filesystem, $path) {
        assert(is_string($path));
        $this->flightcontrol = $flightcontrol;
        $this->filesystem = $filesystem;
        $this->path = self::normalize($path);
    }

    /**
     * @return  string
     */
    public function path() {
        return $this->path;
    }

    /**
     * @return string
     */
    public function name() {
        $parts = explode("/", $this->path);
        return end($parts);
    }

    /**
     * @return string
     */
    public function mimetype() {
        return $this->filesystem->getMimetype($this->path);
    }

    /**
     * @return bool
     */
    abstract function isFile();

    // Helper

    private static function normalize($path) {
        if (substr($path, -1) == "/") {
            $path = substr($path, 0, strlen($path) - 1);
        }
        return $path;
    }

    // Remove these:

    /**
     * @return File|null
     */
    public function toFile() {
        return null;
    }

    /**
     * @return Directory|null
     */
    public function toDirectory() {
        return null;
    }

}<commit_msg>comments<commit_after><?php

namespace Lechimp\Flightcontrol;

/**
 * Some object on the filesystem.
 */
abstract class FSObject {
    /**
     * @var Flightcontrol 
     */
    protected $flightcontrol;

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

    /**
     * @var string
     */
    protected $path;

    /**
     * @param   \Lechimp\Flightcontrol\Flightcontrol    $flightcontrol
     * @param   \League\Flysystem\Filesytem             $filesystem
     * @param   string  $path
     */
    public function __construct(Flightcontrol $flightcontrol, \League\Flysystem\Filesystem $filesystem, $path) {
        assert(is_string($path));
        $this->flightcontrol = $flightcontrol;
        $this->filesystem = $filesystem;
        $this->path = self::normalize($path);
    }

    /**
     * @return  string
     */
    public function path() {
        return $this->path;
    }

    /**
     * @return string
     */
    public function name() {
        $parts = explode("/", $this->path);
        return end($parts);
    }

    /**
     * @return string
     */
    public function mimetype() {
        return $this->filesystem->getMimetype($this->path);
    }

    // Helper

    private static function normalize($path) {
        if (substr($path, -1) == "/") {
            $path = substr($path, 0, strlen($path) - 1);
        }
        return $path;
    }

    // Remove these:
    // They will be good for a typechecker.

    /**
     * @return File|null
     */
    public function toFile() {
        return null;
    }

    /**
     * @return Directory|null
     */
    public function toDirectory() {
        return null;
    }

    // Or this:
    // This will be a little less verbose when implementing stuff.

    /**
     * @return bool
     */
    abstract function isFile();

}
{'fraction_non_alphanumeric': 0.14011840992387933, 'fraction_numerical': 0.0016915703411333521, 'mean_word_length': 1.820349761526232, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 19, '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': '6226581', 'n_tokens_mistral': 1104, 'n_tokens_neox': 1040, 'n_words': 231}