MOON
Server: Apache
System: Linux server1.studioinfinity.com.br 2.6.32-954.3.5.lve1.4.90.el6.x86_64 #1 SMP Tue Feb 21 12:26:30 UTC 2023 x86_64
User: artinside (517)
PHP: 7.4.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: /home/artinside/www/sabbry/vendor/frenet/frenet-php/src/ObjectType/Entity/Shipping/Quote.php
<?php

declare(strict_types = 1);

namespace Frenet\ObjectType\Entity\Shipping;

use Frenet\ObjectType\EntityAbstract;

/**
 * Class Quote
 *
 * @package Frenet\ObjectType\Entity\Shipping
 */
class Quote extends EntityAbstract implements QuoteInterface
{
    /**
     * @var Quote\ServiceFactory
     */
    private $serviceFactory;

    /**
     * @var array
     */
    protected $fieldMapping = [
        'ShippingSevicesArray' => 'shipping_services',
    ];

    public function __construct(
        \Frenet\Framework\Data\SerializerInterface $serializer,
        Quote\ServiceFactory $serviceFactory,
        array $data = []
    ) {
        parent::__construct($serializer, $data);
        $this->serviceFactory = $serviceFactory;
    }

    /**
     * @return array
     */
    public function getShippingServices()
    {
        return $this->prepareShippingServices();
    }

    /**
     * @return array
     */
    private function prepareShippingServices()
    {
        $services = (array) $this->getData(self::FIELD_SHIPPING_SERVICES);
        $result = [];

        /** @var array $service */
        foreach ($services as $service) {
            $result[] = $this->serviceFactory->create(['data' => (array) $service]);
        }

        return $result;
    }
}