<commit_before><?php

namespace WellCommerce\Bundle\OrderBundle\Adapter;

use Symfony\Component\HttpFoundation\Response;
use WellCommerce\Bundle\CoreBundle\DependencyInjection\AbstractContainerAware;
use WellCommerce\Bundle\CoreBundle\Doctrine\Repository\RepositoryInterface;
use WellCommerce\Bundle\CoreBundle\Manager\ManagerInterface;
use WellCommerce\Bundle\OrderBundle\Entity\OrderStatus;
use WellCommerce\Bundle\OrderBundle\Entity\OrderStatusHistory;
use WellCommerce\Bundle\OrderBundle\Entity\ShipmentInterface;

/**
 * Class AbstractShipmentAdapter
 *
 * @author  <NAME> <<EMAIL>>
 */
abstract class AbstractShipmentAdapter extends AbstractContainerAware implements ShipmentAdapterInterface
{
    public function addShipment(ShipmentInterface $shipment, array $formValues): Response
    {
        // TODO: Implement addShipment() method.
    }
    
    public function generateLabel(ShipmentInterface $shipment)
    {
        // TODO: Implement generateLabel() method.
    }
    
    public function getLabel(ShipmentInterface $shipment)
    {
        // TODO: Implement getLabel() method.
    }
    
    public function getLabels(string $date)
    {
        // TODO: Implement getLabels() method.
    }
    
    protected function getShipmentRepository(): RepositoryInterface
    {
        return $this->get('shipment.repository');
    }
    
    protected function createOrderStatusHistory(ShipmentInterface $shipment, array $formValues): OrderStatusHistory
    {
        /** @var ManagerInterface $manager */
        $manager       = $this->get('order_status_history.manager');
        $order         = $shipment->getOrder();
        $notify        = (bool)$formValues['required_data']['notify'];
        $comment       = $formValues['required_data']['comment'];
        $orderStatusId = $formValues['required_data']['orderStatus'];
        
        /** @var OrderStatus $orderStatus */
        $orderStatus = $this->get('order_status.repository')->find($orderStatusId);
        
        if (!$orderStatus instanceof OrderStatus) {
            throw new \Exception('Wrong order status given.');
        }
        
        $order->setCurrentStatus($orderStatus);
        
        /** @var OrderStatusHistory $orderStatusHistory */
        $orderStatusHistory = $this->get('order_status_history.factory')->create();
        $orderStatusHistory->setNotify($notify);
        $orderStatusHistory->setComment($comment);
        $orderStatusHistory->setOrder($order);
        $orderStatusHistory->setOrderStatus($order->getCurrentStatus());
        
        $manager->createResource($orderStatusHistory);
        
        return $orderStatusHistory;
    }
}
<commit_msg>Add ShipmentBundle<commit_after><?php

namespace WellCommerce\Bundle\OrderBundle\Adapter;

use WellCommerce\Bundle\CoreBundle\DependencyInjection\AbstractContainerAware;
use WellCommerce\Bundle\CoreBundle\Manager\ManagerInterface;
use WellCommerce\Bundle\OrderBundle\Entity\OrderStatus;
use WellCommerce\Bundle\OrderBundle\Entity\OrderStatusHistory;
use WellCommerce\Bundle\OrderBundle\Entity\Shipment;
use WellCommerce\Bundle\OrderBundle\Manager\ShipmentManager;

/**
 * Class AbstractShipmentAdapter
 *
 * @author  <NAME> <<EMAIL>>
 */
abstract class AbstractShipmentAdapter extends AbstractContainerAware implements ShipmentAdapterInterface
{
    protected $manager;
    
    public function __construct(ShipmentManager $manager)
    {
        $this->manager = $manager;
    }
    
    protected function createOrderStatusHistory(Shipment $shipment, array $formValues): OrderStatusHistory
    {
        /** @var ManagerInterface $manager */
        $manager       = $this->get('order_status_history.manager');
        $order         = $shipment->getOrder();
        $notify        = (bool)$formValues['required_data']['notify'];
        $comment       = $formValues['required_data']['comment'];
        $orderStatusId = $formValues['required_data']['orderStatus'];
        
        /** @var OrderStatus $orderStatus */
        $orderStatus = $this->get('order_status.repository')->find($orderStatusId);
        
        if (!$orderStatus instanceof OrderStatus) {
            throw new \Exception('Wrong order status given.');
        }
        
        $order->setCurrentStatus($orderStatus);
        
        /** @var OrderStatusHistory $orderStatusHistory */
        $orderStatusHistory = $this->get('order_status_history.factory')->create();
        $orderStatusHistory->setNotify($notify);
        $orderStatusHistory->setComment($comment);
        $orderStatusHistory->setOrder($order);
        $orderStatusHistory->setOrderStatus($order->getCurrentStatus());
        
        $manager->createResource($orderStatusHistory);
        
        return $orderStatusHistory;
    }
}

{'fraction_non_alphanumeric': 0.11494011346921622, 'fraction_numerical': 0.0, 'mean_word_length': 3.3992606284658042, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 37, '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': '5197679', 'n_tokens_mistral': 1207, 'n_tokens_neox': 1234, 'n_words': 202}