<commit_before><?php namespace Ordercloud\Entities\Orders;

use Ordercloud\Entities\Organisations\OrganisationShort;

class MerchantItems
{
    /**
     * @var OrganisationShort
     */
    private $merchant;
    /**
     * @var array|OrderItem[]
     */
    private $items;

    /**
     * @param OrganisationShort $merchant
     * @param array|OrderItem[] $items
     */
    public function __construct(OrganisationShort $merchant, array $items = [])
    {
        $this->merchant = $merchant;
        $this->items = $items;
    }

    /**
     * @param Order $order
     *
     * @return array|static[]
     */
    public static function createFromOrder(Order $order)
    {
        $groupedItems = [];

        foreach ($order->getItems() as $item) {
            $merchantId = $item->getDetail()->getOrganisation()->getId();

            if (array_key_exists($merchantId, $groupedItems)) {
                $groupedItems[$merchantId]['items'][] = $item;
            }
            else {
                $groupedItems[$merchantId] = [];
                $groupedItems[$merchantId]['org'] = $item->getDetail()->getOrganisation();
                $groupedItems[$merchantId]['items'] = [$item];
            }
        }

        $merchantItems = [];

        foreach ($groupedItems as $grouping) {
            $merchantItems[] = new static($grouping['org'], $grouping['items']);
        }

        return $merchantItems;
    }

    /**
     * @return OrganisationShort
     */
    public function getMerchant()
    {
        return $this->merchant;
    }

    /**
     * @return array|OrderItem[]
     */
    public function getItems()
    {
        return $this->items;
    }
<commit_msg>Updated MerchantItems with new OrderItemMerchant DTO<commit_after><?php namespace Ordercloud\Entities\Orders;

class MerchantItems
{
    /**
     * @var OrderItemMerchant
     */
    private $merchant;
    /**
     * @var array|OrderItem[]
     */
    private $items;

    /**
     * @param OrderItemMerchant $merchant
     * @param array|OrderItem[] $items
     */
    public function __construct(OrderItemMerchant $merchant, array $items = [])
    {
        $this->merchant = $merchant;
        $this->items = $items;
    }

    /**
     * @param Order $order
     *
     * @return array|static[]
     */
    public static function createFromOrder(Order $order)
    {
        $groupedItems = [];

        foreach ($order->getItems() as $item) {
            $merchantId = $item->getDetail()->getOrganisation()->getId();

            if (array_key_exists($merchantId, $groupedItems)) {
                $groupedItems[$merchantId]['items'][] = $item;
            }
            else {
                $groupedItems[$merchantId] = [];
                $groupedItems[$merchantId]['org'] = $item->getDetail()->getOrganisation();
                $groupedItems[$merchantId]['items'] = [$item];
            }
        }

        $merchantItems = [];

        foreach ($groupedItems as $grouping) {
            $merchantItems[] = new static($grouping['org'], $grouping['items']);
        }

        return $merchantItems;
    }

    /**
     * @return OrderItemMerchant
     */
    public function getMerchant()
    {
        return $this->merchant;
    }

    /**
     * @return array|OrderItem[]
     */
    public function getItems()
    {
        return $this->items;
    }

{'fraction_non_alphanumeric': 0.1468218442256043, 'fraction_numerical': 0.0, 'mean_word_length': 2.0252707581227436, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 23, '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': '5092354', 'n_tokens_mistral': 992, 'n_tokens_neox': 966, 'n_words': 171}