<commit_before><?php

/*
 * This file is part of the Sylius package.
 *
 * (c) <NAME>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Sylius\Bundle\ResourceBundle\Event;

use Symfony\Component\EventDispatcher\GenericEvent;

/**
 * Resource event.
 *
 * @author <NAME> <<EMAIL>>
 */
class ResourceEvent extends GenericEvent
{
    const TYPE_SUCCESS  = 'success';
    const TYPE_ERROR    = 'error';
    const TYPE_INFO     = 'info';
    const TYPE_WARNING  = 'warning';

    protected $allowed_types = array(self::TYPE_SUCCESS, self::TYPE_ERROR, self::TYPE_INFO, self::TYPE_WARNING);

    /**
     * Indicate if an error has been detected
     *
     * @var boolean
     */
    protected $error = false;

    /**
     * Message type
     *
     * @var string
     */
    protected $message_type = '';

    /**
     * Message
     *
     * @var string
     */
    protected $message = '';

    /**
     * Message parameters
     *
     * @var array
     */
    protected $message_params = array();

    /**
     * Get error property
     *
     * @return boolean $error
     */
    public function hasError()
    {
        return $this->error;
    }

    /**
     * Set error property
     *
     * @return boolean $error
     */
    public function setError($error)
    {
        return $this->error = $error;
    }

    /**
     * Get message_type property
     *
     * @return string $message_type
     */
    public function getMessageType()
    {
        return $this->message_type;
    }

    /**
     * Set message_type property
     *
     * @return string $message_type
     */
    public function setMessageType($message_type)
    {
        if(!in_array($message_type, $this->allowed_types)) {
            throw new \InvalidArgumentException('Allowed message types are \''.implode(', ', $this->allowed_types).'\'');
        }

        return $this->message_type = $message_type;
    }

    /**
     * Get message property
     *
     * @return string $message
     */
    public function getMessage()
    {
        return $this->message;
    }

    /**
     * Set message property
     *
     * @return string $message
     */
    public function setMessage($message)
    {
        return $this->message = $message;
    }

    /**
     * Get message_params property
     *
     * @return string $message_params
     */
    public function getMessageParams()
    {
        return $this->message_params;
    }

    /**
     * Set message_params property
     *
     * @return string $message_params
     */
    public function setMessageParams($message_params)
    {
        return $this->message_params = $message_params;
    }
}<commit_msg>Remove Setters + Add method to stop<commit_after><?php

/*
 * This file is part of the Sylius package.
 *
 * (c) <NAME>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Sylius\Bundle\ResourceBundle\Event;

use Symfony\Component\EventDispatcher\GenericEvent;

/**
 * Resource event.
 *
 * @author <NAME> <<EMAIL>>
 */
class ResourceEvent extends GenericEvent
{
    const TYPE_ERROR    = 'error';
    const TYPE_WARNING  = 'warning';

    public function stopWithError($message, $params = array())
    {
        $this->error = true;
        $this->message_type = self::TYPE_ERROR;
        $this->message = $message;
        $this->message_params = $params;
    }

    public function stopWithWarning($message, $params = array())
    {
        $this->error = true;
        $this->message_type = self::TYPE_WARNING;
        $this->message = $message;
        $this->message_params = $params;
    }

    /**
     * Indicate if an error has been detected
     *
     * @var boolean
     */
    protected $error = false;

    /**
     * Message type
     *
     * @var string
     */
    protected $message_type = '';

    /**
     * Message
     *
     * @var string
     */
    protected $message = '';

    /**
     * Message parameters
     *
     * @var array
     */
    protected $message_params = array();

    /**
     * Get error property
     *
     * @return boolean $error
     */
    public function hasStopped()
    {
        return $this->error === true;
    }

    /**
     * Get message_type property
     *
     * @return string $message_type
     */
    public function getMessageType()
    {
        return $this->message_type;
    }

    /**
     * Get message property
     *
     * @return string $message
     */
    public function getMessage()
    {
        return $this->message;
    }

    /**
     * Get message_params property
     *
     * @return string $message_params
     */
    public function getMessageParams()
    {
        return $this->message_params;
    }
}
{'fraction_non_alphanumeric': 0.11975180972078593, 'fraction_numerical': 0.0, 'mean_word_length': 2.024390243902439, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 33, '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': '413443', 'n_tokens_mistral': 1413, 'n_tokens_neox': 1386, 'n_words': 348}