<commit_before><?php

namespace Igniter\Flame\Database\Attach;

use BadMethodCallException;
use Exception;
use Illuminate\Support\Collection;
use League\Flysystem\FilesystemInterface;
use League\Glide\ServerFactory;

class Manipulator
{
    protected $file;

    protected $manipulations;

    protected $driver = 'gd';

    /**
     * @var \League\Flysystem\FilesystemInterface
     */
    protected $source;

    protected $tempFilePath;

    public function __construct($file)
    {
        $this->file = $file;
        $this->manipulations = new Collection();
    }

    public static function make($file)
    {
        return new static($file);
    }

    public function __call($name, $arguments)
    {
        if (!in_array($this->getAvailableGlideParameters(), $name))
            throw new BadMethodCallException("Manipulation '{$name}' is not a valid glide parameter");

        $this->manipulations()->push($name, $arguments);

        return $this;
    }

    public function useDriver($driver)
    {
        if (!in_array($driver, ['gd', 'imagick']))
            throw new Exception("Driver must be 'gd' or 'imagick'. '{$driver}' provided.");

        $this->driver = $driver;

        return $this;
    }

    public function useSource($source)
    {
        if (!$source instanceof FilesystemInterface)
            throw new Exception('Source must be instance of '.FilesystemInterface::class);

        $this->source = $source;

        return $this;
    }

    public function manipulations()<commit_msg>Fixes #15<commit_after><?php

namespace Igniter\Flame\Database\Attach;

use BadMethodCallException;
use Exception;
use Illuminate\Support\Collection;
use League\Flysystem\FilesystemInterface;
use League\Glide\ServerFactory;

class Manipulator
{
    protected $file;

    protected $manipulations;

    protected $driver = 'gd';

    /**
     * @var \League\Flysystem\FilesystemInterface
     */
    protected $source;

    protected $tempFilePath;

    public function __construct($file)
    {
        $this->file = $file;
        $this->manipulations = new Collection();
    }

    public static function make($file)
    {
        return new static($file);
    }

    public function __call($name, $arguments)
    {
        if (!in_array($name, $this->getAvailableGlideParameters()))
            throw new BadMethodCallException("Manipulation '{$name}' is not a valid glide parameter");

        $this->manipulations()->push($name, $arguments);

        return $this;
    }

    public function useDriver($driver)
    {
        if (!in_array($driver, ['gd', 'imagick']))
            throw new Exception("Driver must be 'gd' or 'imagick'. '{$driver}' provided.");

        $this->driver = $driver;

        return $this;
    }

    public function useSource($source)
    {
        if (!$source instanceof FilesystemInterface)
            throw new Exception('Source must be instance of '.FilesystemInterface::class);

        $this->source = $source;

        return $this;
    }

    public function manipulations()
{'fraction_non_alphanumeric': 0.12220026350461133, 'fraction_numerical': 0.0006587615283267457, 'mean_word_length': 2.805764411027569, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, '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': '2746315', 'n_tokens_mistral': 859, 'n_tokens_neox': 825, 'n_words': 214}