<commit_before><?php

namespace LukePOLO\LaraCart;

use LukePOLO\LaraCart\Contracts\LaraCartContract;

/**
 * Class LaraCart
 *
 * @package LukePOLO\LaraCart
 */
class LaraCart implements LaraCartContract
{
    public $cart;

    /**
     * @param LaraCartContract $laraCartService | LukePOLO\LaraCart\LaraCart $laraCartService
     */
    function __construct()
    {
        $this->session = app('session');
        $this->events = app('events');
        $this->setInstance($this->session->get('laracart.instance', 'default'));
    }

    /**
     * Sets and Gets the instance of the cart in the session we should be using
     *
     * @param string $instance
     */
    public function setInstance($instance = 'default')
    {
        $this->instance = $instance;

        $this->get($instance);

        // set in the session that we are using a different instance
        $this->session->set('laracart.instance', $instance);

        $this->events->fire('laracart.new');
    }

    /**
     * Gets the instance in the session
     *
     * @param string $instance
     *
     * @return $this cart instance
     */
    public function get($instance = 'default')
    {
        if (empty($this->cart = $this->session->get(config('laracart.cache_prefix', 'laracart.') . $instance))) {
            $this->cart = new Cart($instance);
        }

        return $this->cart;
    }

    /**
     * Formats the number into a money format based on the locale and international formats
     *
     * @param $number
     * @param $locale
     * @param $internationalFormat
     *
     * @return string
     */
    public function formatMoney($number, $locale = null, $internationalFormat = null)
    {
        if (empty($locale) === true) {
            $locale = config('laracart.locale', 'en_US');
        }

        if (empty($internationalFormat) === true) {
            $internationalFormat = config('laracart.international_format');
        }

        setlocale(LC_MONETARY, $locale);
        if ($internationalFormat) {
            return money_format('%i', $number);<commit_msg>removing need for createing new apps and events inside the constructor<commit_after><?php

namespace LukePOLO\LaraCart;

use LukePOLO\LaraCart\Contracts\LaraCartContract;

/**
 * Class LaraCart
 *
 * @package LukePOLO\LaraCart
 */
class LaraCart implements LaraCartContract
{
    public $cart;

    /**
     * @param LaraCartContract $laraCartService | LukePOLO\LaraCart\LaraCart $laraCartService
     */
    function __construct()
    {
        $this->setInstance(\Session::get('laracart.instance', 'default'));
    }

    /**
     * Sets and Gets the instance of the cart in the session we should be using
     *
     * @param string $instance
     */
    public function setInstance($instance = 'default')
    {
        $this->instance = $instance;

        $this->get($instance);

        // set in the session that we are using a different instance
        \Session::set('laracart.instance', $instance);

        \Event::fire('laracart.new');
    }

    /**
     * Gets the instance in the session
     *
     * @param string $instance
     *
     * @return $this cart instance
     */
    public function get($instance = 'default')
    {
        if (empty($this->cart = \Session::get(config('laracart.cache_prefix', 'laracart.') . $instance))) {
            $this->cart = new Cart($instance);
        }

        return $this->cart;
    }

    /**
     * Formats the number into a money format based on the locale and international formats
     *
     * @param $number
     * @param $locale
     * @param $internationalFormat
     *
     * @return string
     */
    public function formatMoney($number, $locale = null, $internationalFormat = null)
    {
        if (empty($locale) === true) {
            $locale = config('laracart.locale', 'en_US');
        }

        if (empty($internationalFormat) === true) {
            $internationalFormat = config('laracart.international_format');
        }

        setlocale(LC_MONETARY, $locale);
        if ($internationalFormat) {
            return money_format('%i', $number);
{'fraction_non_alphanumeric': 0.13041362530413625, 'fraction_numerical': 0.0, 'mean_word_length': 2.4286905754795662, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 25, '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': '2592359', 'n_tokens_mistral': 1199, 'n_tokens_neox': 1166, 'n_words': 287}