<commit_before><?php

namespace AppBundle\SlackCommand\Jemy;

use AppBundle\SlackCommand\AbstractCommand;
use Domain\Model\Lunch\MenuItem;
use Domain\Model\Lunch\Order;
use Domain\UseCase\Lunch\AddItemToOrder;
use Infrastructure\File\OrderStorage;
use Slack\Channel;
use Slack\User;
use Spatie\Regex\Regex;

class JemCommand extends AbstractCommand implements AddItemToOrder\Responder
{
    public function execute(string $message, User $user, Channel $channel)
    {
        parent::execute($message, $user, $channel);

        $regex = Regex::match('/jem (\w+) (\d{1,3})/', $message);

        if ($regex->hasMatch()) {
            $this->addItemToOrder($regex->group(1), $regex->group(2));

            return true;
        }

        return false;
    }

    protected function addItemToOrder(string $restaurant, int $position)
    {
        $command = new AddItemToOrder\Command($restaurant, $this->user->getId(), $position);

        $useCase = new AddItemToOrder(new OrderStorage());
        $useCase->execute($command, $this);
    }

    public function successfullyAddedItemToOrder(Order $order, string $userName, MenuItem $addedMenuItem)
    {
        $price = $addedMenuItem->getPrice()->getZl() . ',' . $addedMenuItem->getPrice()->getGr() . ' zł';
        $this->reply($addedMenuItem->getName() . ' dla Ciebie za ' . $price);
    }

    public function addingItemToOrderFailed(\Exception $e)
    {
        $this->reply('nie udało mi się zarejestrować Twojego zamówienia');
    }
}<commit_msg>Add aliases to jem command<commit_after><?php

namespace AppBundle\SlackCommand\Jemy;

use AppBundle\SlackCommand\AbstractCommand;
use Domain\Model\Lunch\MenuItem;
use Domain\Model\Lunch\Order;
use Domain\UseCase\Lunch\AddItemToOrder;
use Infrastructure\File\OrderStorage;
use Slack\Channel;
use Slack\User;
use Spatie\Regex\Regex;

class JemCommand extends AbstractCommand implements AddItemToOrder\Responder
{
    public function execute(string $message, User $user, Channel $channel)
    {
        parent::execute($message, $user, $channel);

        $regex = Regex::match('/(?:jem|biore|biorę) (\w+) (\d{1,3})/iu', $message);

        if ($regex->hasMatch()) {
            $this->addItemToOrder($regex->group(1), $regex->group(2));

            return true;
        }

        return false;
    }

    protected function addItemToOrder(string $restaurant, int $position)
    {
        $command = new AddItemToOrder\Command($restaurant, $this->user->getId(), $position);

        $useCase = new AddItemToOrder(new OrderStorage());
        $useCase->execute($command, $this);
    }

    public function successfullyAddedItemToOrder(Order $order, string $userName, MenuItem $addedMenuItem)
    {
        $price = $addedMenuItem->getPrice()->getZl() . ',' . $addedMenuItem->getPrice()->getGr() . ' zł';
        $this->reply($addedMenuItem->getName() . ' dla Ciebie za ' . $price);
    }

    public function addingItemToOrderFailed(\Exception $e)
    {
        $this->reply('nie udało mi się zarejestrować Twojego zamówienia');
    }
}
{'fraction_non_alphanumeric': 0.14281013491280026, 'fraction_numerical': 0.0026324448831852583, 'mean_word_length': 3.5170876671619613, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 31, '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': '5387426', 'n_tokens_mistral': 951, 'n_tokens_neox': 926, 'n_words': 192}