<commit_before><?php

namespace Glide\Manipulators;

use Glide\ParameterException;
use Intervention\Image\Image;

class Size implements Manipulator
{
    private $maxImageSize;
    private $width;
    private $height;
    private $fit = 'clip';
    private $cropPosition = 'center';
    private $cropRectangle;
    private $orientation = 'auto';

    public function __construct($maxImageSize = null)
    {
        $this->maxImageSize = $maxImageSize;
    }

    public function setWidth($width)
    {
        if (!ctype_digit($width)) {
            throw new ParameterException('The width must be a valid number.');
        }

        if ($width <= 0) {
            throw new ParameterException('The width must be greater than 0.');
        }

        $this->width = $width;
    }

    public function setHeight($height)
    {
        if (!ctype_digit($height)) {
            throw new ParameterException('Height must be a valid number.');
        }

        if ($height <= 0) {
            throw new ParameterException('Weight must be greater than 0.');
        }

        $this->height = $height;
    }

    public function setFit($fit)
    {
        if (!in_array($fit, ['clip', 'scale', 'crop'])) {
            throw new ParameterException('Fit only accepts "clip", "scale" or "crop".');
        }

        if (is_null($this->width) or is_null($this->height)) {
            throw new ParameterException('The width or height must be set when using fit.');
        }

        $this->fit = $fit;<commit_msg>Fix bug preventing the fit function from working.<commit_after><?php

namespace Glide\Manipulators;

use Glide\ParameterException;
use Intervention\Image\Image;

class Size implements Manipulator
{
    private $maxImageSize;
    private $width;
    private $height;
    private $fit = 'clip';
    private $cropPosition = 'center';
    private $cropRectangle;
    private $orientation = 'auto';

    public function __construct($maxImageSize = null)
    {
        $this->maxImageSize = $maxImageSize;
    }

    public function setWidth($width)
    {
        if (!ctype_digit($width)) {
            throw new ParameterException('The width must be a valid number.');
        }

        if ($width <= 0) {
            throw new ParameterException('The width must be greater than 0.');
        }

        $this->width = $width;
    }

    public function setHeight($height)
    {
        if (!ctype_digit($height)) {
            throw new ParameterException('Height must be a valid number.');
        }

        if ($height <= 0) {
            throw new ParameterException('Weight must be greater than 0.');
        }

        $this->height = $height;
    }

    public function setFit($fit)
    {
        if (!in_array($fit, ['clip', 'scale', 'crop'])) {
            throw new ParameterException('Fit only accepts "clip", "scale" or "crop".');
        }

        $this->fit = $fit;
{'fraction_non_alphanumeric': 0.12227225493591964, 'fraction_numerical': 0.0027710426047800486, 'mean_word_length': 2.338728323699422, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 13, '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': '5493010', 'n_tokens_mistral': 826, 'n_tokens_neox': 794, 'n_words': 236}