Passed
Pull Request — master (#5)
by Sergey
02:15
created

Counterparty::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 1
c 1
b 0
f 1
dl 0
loc 3
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SergeyNezbritskiy\NovaPoshta\Models;
6
7
use RuntimeException;
8
use SergeyNezbritskiy\NovaPoshta\Connection;
9
use SergeyNezbritskiy\NovaPoshta\ModelInterface;
10
use SergeyNezbritskiy\NovaPoshta\NovaPoshtaApiException;
11
12
class Counterparty implements ModelInterface
13
{
14
    private const MODEL_NAME = 'Counterparty';
15
    private Connection $connection;
16
17
    /**
18
     * @param Connection $connection
19
     */
20
    public function __construct(Connection $connection)
21
    {
22
        $this->connection = $connection;
23
    }
24
25
    /**
26
     * @param string $counterpartyRef
27
     * @param string $counterpartyProperty
28
     * @return array
29
     * @throws NovaPoshtaApiException
30
     */
31
    public function getCounterpartyAddresses(string $counterpartyRef, string $counterpartyProperty): array
32
    {
33
        $params = [
34
            'Ref' => $counterpartyRef,
35
            'CounterpartyProperty' => $counterpartyProperty,
36
        ];
37
        return $this->connection->post('Counterparty', 'getCounterpartyAddresses', $params);
38
    }
39
}
40