Your IP : 216.73.216.86


Current Path : /var/www/homesaver/www/bitrix/modules/ipol.sdek/classes/lib/Api/Adapter/
Upload File :
Current File : /var/www/homesaver/www/bitrix/modules/ipol.sdek/classes/lib/Api/Adapter/ResponseHeadersTrait.php

<?php
namespace Ipolh\SDEK\Api\Adapter;

trait ResponseHeadersTrait
{
    protected $arHeaders = [];

    public function setHeaders(array $headers = [])
    {
        $this->arHeaders = $headers;
    }

    /**
     * @param string $headerName
     * @param int $index - in some cases there can be more than one header with one name.
     * in that case we can parse them by index.
     * But for 99% cases we can suggest that index other as 0 will not give more info.
     * @return string
     */
    public function getHeader($headerName, $index = 0)
    {
        if (array_key_exists($headerName, $this->arHeaders) &&
            array_key_exists($index, $this->arHeaders[$headerName])
        ) {
            return $this->arHeaders[$headerName][$index];
        } else {
            return '';
        }
    }
}