<commit_before><?php
/**
 * Created by <NAME> - 29/09/2017 12:02 PM
 */

namespace Enea\Cashier\Modifiers\Discounts;

use Enea\Cashier\IsJsonable;
use Enea\Cashier\Modifiers\DiscountContract;
use Illuminate\Support\Collection;

class Discount implements DiscountContract
{
    use IsJsonable;

    /**
     * @var int|string
     */
    protected $key;

    /**
     * @var string
     */
    protected $description;

    /**
     * @var int
     */
    protected $percentage;

    /**
     * @var array
     */
    protected $additionalAttributes;

    /**
     * Discount constructor.
     *
     * @param string|int $key
     * @param string $description
     * @param int $percentage
     * @param Collection $additionalAttributes
     */
    public function __construct($key, $description, $percentage, Collection $additionalAttributes = null)
    {
        $this->key = $key;
        $this->description = $description;
        $this->percentage = $percentage;
        $this->additionalAttributes = $additionalAttributes ?: collect();
    }

    /**
     * Returns a new instance.
     *
     * @param $key
     * @param $description
     * @param $percentage
     * @param Collection $attributes
     * @return static
     */
    static public function make($key, $description, $percentage, Collection $attributes = null)
    {
        return new static($key, $description, $percentage, $attributes);
    }

    /**
     * Returns a new instance.
     *
     * @param $description
     * @param $percentage
     * @param Collection $attributes
     * @return static
     */
    static public function generate($description, $percentage, Collection $attributes = null)
    {
        $key = hash('adler32', time(), false);
        return static::make($key, $description, $percentage, $attributes);
    }

    /**
     * Returns the discount key.
     *
     * @return int|string
     */
    public function getDiscountCode()
    {
        return $this->key;
    }

    /**
     * Returns discount  percentage.
     *
     * @return int<commit_msg>Fix the generated method on Discount class<commit_after><?php
/**
 * Created by <NAME> - 29/09/2017 12:02 PM
 */

namespace Enea\Cashier\Modifiers\Discounts;

use Enea\Cashier\IsJsonable;
use Enea\Cashier\Modifiers\DiscountContract;
use Illuminate\Support\Collection;

class Discount implements DiscountContract
{
    use IsJsonable;

    /**
     * @var int|string
     */
    protected $key;

    /**
     * @var string
     */
    protected $description;

    /**
     * @var int
     */
    protected $percentage;

    /**
     * @var array
     */
    protected $additionalAttributes;

    /**
     * Discount constructor.
     *
     * @param string|int $key
     * @param string $description
     * @param int $percentage
     * @param Collection $additionalAttributes
     */
    public function __construct($key, $description, $percentage, Collection $additionalAttributes = null)
    {
        $this->key = $key;
        $this->description = $description;
        $this->percentage = $percentage;
        $this->additionalAttributes = $additionalAttributes ?: collect();
    }

    /**
     * Returns a new instance.
     *
     * @param $key
     * @param $description
     * @param $percentage
     * @param Collection $attributes
     * @return static
     */
    static public function make($key, $description, $percentage, Collection $attributes = null)
    {
        return new static($key, $description, $percentage, $attributes);
    }

    /**
     * Returns a new instance.
     *
     * @param $description
     * @param $percentage
     * @param Collection $attributes
     * @return static
     */
    static public function generate($description, $percentage, Collection $attributes = null)
    {
        $key = hash('adler32', microtime(true), false);
        return static::make($key, $description, $percentage, $attributes);
    }

    /**
     * Returns the discount key.
     *
     * @return int|string
     */
    public function getDiscountCode()
    {
        return $this->key;
    }

    /**
     * Returns discount  percentage.
     *
     * @return int
{'fraction_non_alphanumeric': 0.12270531400966184, 'fraction_numerical': 0.00676328502415459, 'mean_word_length': 2.3154523618895118, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 15, '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': '1064854', 'n_tokens_mistral': 1217, 'n_tokens_neox': 1176, 'n_words': 293}