Completed
Push — master ( 77d67e...c43ed0 )
by Gilmar
03:18
created

Client::renderHeader()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 7
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of gpupo/adyen-sdk
5
 *
6
 * (c) Gilmar Pupo <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 *
11
 * For more information, see
12
 * <http://www.g1mr.com/adyen-sdk/>.
13
 */
14
15
namespace Gpupo\AdyenSdk\Client;
16
17
use Gpupo\CommonSdk\Client\ClientAbstract;
18
use Gpupo\CommonSdk\Client\ClientInterface;
19
20
class Client extends ClientAbstract implements ClientInterface
21
{
22
    public function getDefaultOptions()
23
    {
24
        return [
25
            'client_user'     => false,
26
            'client_password' => false,
27
            'base_url'        => '{PROTOCOL}://pal-{VERSION}.adyen.com/pal/servlet/Payment/v12',
28
            'protocol'        => 'https',
29
            'version'         => 'test',
30
            'verbose'         => false,
31
            'sslVersion'      => 'SecureTransport',
32
            'cacheTTL'        => 3600,
33
            'sslVerifyPeer'   => true,
34
        ];
35
    }
36
37
    protected function renderAuthorization()
38
    {
39
        foreach (['client_user', 'client_password'] as $key) {
40
            $value = $this->getOptions()->get($key);
41
            if (empty($value)) {
42
                throw new \InvalidArgumentException('[' . $key . '] ausente!');
43
            }
44
        }
45
46
        return 'Authorization: Basic '
47
            . base64_encode($this->getOptions()->get('client_user') . ':'
48
            . $this->getOptions()->get('client_password'));
49
    }
50
}
51