Passed
Push — master ( 94f1bd...3747ce )
by Jonathan
02:16
created

ARBGetSubscriptionListRequest::setSorting()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 4
ccs 0
cts 3
cp 0
crap 2
rs 10
1
<?php
2
3
namespace CommerceGuys\AuthNet;
4
5
use GuzzleHttp\Client;
6
use CommerceGuys\AuthNet\DataTypes\Paging;
7
use CommerceGuys\AuthNet\DataTypes\Sorting;
8
use CommerceGuys\AuthNet\Request\RequestInterface;
9
10
/**
11
 * Use this method to get subscriptions using Automated Recurring Billing.
12
 */
13
class ARBGetSubscriptionListRequest extends ARBSubscriptionRequest
14
{
15
    protected $searchType;
16
17
    protected $sorting;
18
19
    protected $paging;
20
21
    public function __construct(
22
        Configuration $configuration,
23
        Client $client,
24
        $searchType
25
    ) {
26
        parent::__construct($configuration, $client);
27
        $this->searchType = $searchType;
28
    }
29
30
    /**
31
     * @param \CommerceGuys\AuthNet\DataTypes\Sorting $sorting
32
     * @return $this
33
     */
34
    public function setSorting(Sorting $sorting)
35
    {
36
        $this->sorting = $sorting;
37
        return $this;
38
    }
39
40
    /**
41
     * @param \CommerceGuys\AuthNet\DataTypes\Paging $paging
42
     * @return $this
43
     */
44
    public function setPaging(Paging $paging)
45
    {
46
        $this->paging = $paging;
47
        return $this;
48
    }
49
50
    protected function attachData(RequestInterface $request)
51
    {
52
        $request->addData('searchType', $this->searchType);
53
        if ($this->sorting) {
54
            $request->addDataType($this->sorting);
55
        }
56
        if ($this->paging) {
57
            $request->addDataType($this->paging);
58
        }
59
    }
60
}
61