<commit_before><?php
declare(strict_types = 1);

namespace ISTSI\Services;

use Psr\Container\ContainerInterface;
use \Slim\Http\UploadedFile;

class FileManager
{
    protected $c;
    public $extension;
    public $mimeType;
    public $maxSize;
    public $directory;
    public $filename;

    public function __construct(ContainerInterface $c)
    {
        $this->c = $c;

        $settings = $this->c->get('settings')['files'];
        $this->extension = $settings['extension'];
        $this->mimeType  = $settings['mimeType'];
        $this->maxSize   = $settings['maxSize'] * 1048576;
        $this->directory   = $settings['directory'];
        $this->filename  = $settings['filename'];
    }

    public function parseUpload(UploadedFile $file, string $path)
    {
        if ($this->getExtension($file) !== $this->extension) {
            //TODO: throw new IException(E_FILE_EXTENSION, ['extension' => $this->extension], 'file' . $field);
            die('E_FILE_EXTENSION');
        }
        if ($this->getMimeType($file) !== $this->mimeType) {
            //TODO: throw new IException(E_FILE_MIME_TYPE, ['mimeType' => $this->mimeType], 'file' . $field);
            die('E_FILE_EXTENSION');
        }
        if ($file->getSize() >= $this->maxSize) {
            //TODO: throw new IException(E_FILE_SIZE, ['maxSizeMB' => $this->maxSize], 'file' . $field);
            die('E_FILE_SIZE');
        }

        $file->moveTo($path);
    }

    public function getFilePath(array $map)
    {
        return strtr($this->directory . $this->filename, $map) . '.' . $this->extension;
    }

    public function getExtension(UploadedFile $file)
    {
        return pathinfo($file->getClientFilename(), PATHINFO_EXTENSION);
    }

    public function getMimeType(UploadedFile $file)
    {
        return finfo_file(finfo_open(FILEINFO_MIME_TYPE), $file->file);
    }

    public function deleteFile(string $path)
    {
        if (file_exists($path)) {
            return unlink($path);<commit_msg>Fix typo<commit_after><?php
declare(strict_types = 1);

namespace ISTSI\Services;

use Psr\Container\ContainerInterface;
use \Slim\Http\UploadedFile;

class FileManager
{
    protected $c;
    public $extension;
    public $mimeType;
    public $maxSize;
    public $directory;
    public $filename;

    public function __construct(ContainerInterface $c)
    {
        $this->c = $c;

        $settings = $this->c->get('settings')['files'];
        $this->extension = $settings['extension'];
        $this->mimeType  = $settings['mimeType'];
        $this->maxSize   = $settings['maxSize'] * 1048576;
        $this->directory   = $settings['directory'];
        $this->filename  = $settings['filename'];
    }

    public function parseUpload(UploadedFile $file, string $path)
    {
        if ($this->getExtension($file) !== $this->extension) {
            //TODO: throw new IException(E_FILE_EXTENSION, ['extension' => $this->extension], 'file' . $field);
        }
        if ($this->getMimeType($file) !== $this->mimeType) {
            //TODO: throw new IException(E_FILE_MIME_TYPE, ['mimeType' => $this->mimeType], 'file' . $field);
            die('E_FILE_MIME_TYPE');
        }
        if ($file->getSize() >= $this->maxSize) {
            //TODO: throw new IException(E_FILE_SIZE, ['maxSizeMB' => $this->maxSize], 'file' . $field);
            die('E_FILE_SIZE');
        }

        $file->moveTo($path);
    }

    public function getFilePath(array $map)
    {
        return strtr($this->directory . $this->filename, $map) . '.' . $this->extension;
    }

    public function getExtension(UploadedFile $file)
    {
        return pathinfo($file->getClientFilename(), PATHINFO_EXTENSION);
    }

    public function getMimeType(UploadedFile $file)
    {
        return finfo_file(finfo_open(FILEINFO_MIME_TYPE), $file->file);
    }

    public function deleteFile(string $path)
    {
        if (file_exists($path)) {
            return unlink($path);
{'fraction_non_alphanumeric': 0.15708522440746345, 'fraction_numerical': 0.004034291477559254, 'mean_word_length': 2.745986779981114, 'pattern_counts': {'":': 0, '<': 5, '<?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': '4724173', 'n_tokens_mistral': 1268, 'n_tokens_neox': 1225, 'n_words': 231}