<commit_before><?php
namespace Apitude\File\Services;

use Apitude\Core\Provider\ContainerAwareInterface;
use Apitude\Core\Provider\ContainerAwareTrait;
use Symfony\Component\HttpFoundation\File\File;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use League\Flysystem\Adapter\AbstractAdapter;

abstract class AbstractFileService implements ContainerAwareInterface
{
    use ContainerAwareTrait;

    /**
     * Writes to the filesystem
     *
     * @param UploadedFile $file
     * @param string       $fileName
     */
    public function write(UploadedFile $file, $fileName = null)
    {
        if ($fileName === null) {
            $fileName = $file->getClientOriginalName();
        }

        $fs = fopen($file->getPathname(), 'r');

        $config = [];

        $this->getFileAdapter()->write($fileName, $fs, $config);
    }

    /**
     * Reads from the filesystem
     *
     * @param File $file
     * @return array|false
     */
    public function read(File $file)
    {<commit_msg>Use Config instead of array, create protected settings array on AbstractFileService<commit_after><?php
namespace Apitude\File\Services;

use Apitude\Core\Provider\ContainerAwareInterface;
use Apitude\Core\Provider\ContainerAwareTrait;
use Symfony\Component\HttpFoundation\File\File;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use League\Flysystem\Adapter\AbstractAdapter;
use League\Flysystem\Config;

abstract class AbstractFileService implements ContainerAwareInterface
{
    use ContainerAwareTrait;

    /**
     * @var array
     */
    protected $settings = [];

    /**
     * Writes to the filesystem
     *
     * @param UploadedFile $file
     * @param string       $fileName
     * @return array|false
     */
    public function write(UploadedFile $file, $fileName = null)
    {
        if ($fileName === null) {
            $fileName = $file->getClientOriginalName();
        }

        $fs = fopen($file->getPathname(), 'r');

        $config = new Config($this->settings);

        return $this->getFileAdapter()->writeStream($fileName, $fs, $config);
    }

    /**
     * Reads from the filesystem
     *
     * @param File $file
     * @return array|false
     */
    public function read(File $file)
    {
{'fraction_non_alphanumeric': 0.11581291759465479, 'fraction_numerical': 0.0, 'mean_word_length': 2.9265734265734267, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 12, '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': '1992917', 'n_tokens_mistral': 648, 'n_tokens_neox': 641, 'n_words': 143}