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

Counterparty   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 2
eloc 8
c 1
b 0
f 1
dl 0
loc 26
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getCounterpartyAddresses() 0 7 1
A __construct() 0 3 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