Completed
Branch v4.x (712f3d)
by Dmitry
04:56
created

Campaigns::get()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 8
dl 0
loc 17
rs 9.7
c 0
b 0
f 0

How to fix   Many Parameters   

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

1
<?php
2
declare(strict_types=1);
3
4
namespace Gladyshev\Yandex\Direct\Service;
5
6
use function Gladyshev\Yandex\Direct\get_param_names;
7
8
/**
9
 * Class Campaigns
10
 * @package Gladyshev\Yandex\Direct\Service
11
 */
12
final class Campaigns extends \Gladyshev\Yandex\Direct\AbstractService
13
{
14
    /**
15
     * @param array $Campaigns
16
     * @return array
17
     * @throws \Throwable
18
     *
19
     * @see https://tech.yandex.ru/direct/doc/ref-v5/campaigns/add-docpage/
20
     * @see https://tech.yandex.ru/direct/doc/ref-v5/campaigns/add-text-campaign-docpage/
21
     * @see https://tech.yandex.ru/direct/doc/ref-v5/campaigns/add-dynamic-text-campaign-docpage/
22
     * @see https://tech.yandex.ru/direct/doc/ref-v5/campaigns/add-mobile-app-campaign-docpage/
23
     */
24
    public function add($Campaigns)
25
    {
26
        return $this->call([
27
            'method' => 'add',
28
            'params' => [
29
                'Campaigns' => $Campaigns
30
            ]
31
        ]);
32
    }
33
34
    /**
35
     * @param array $SelectionCriteria
36
     * @return array
37
     * @throws \Throwable
38
     *
39
     * @see https://tech.yandex.ru/direct/doc/ref-v5/campaigns/archive-docpage/
40
     */
41
    public function archive($SelectionCriteria)
42
    {
43
        return $this->call([
44
            'method' => 'archive',
45
            'params' => [
46
                'SelectionCriteria' => $SelectionCriteria
47
            ]
48
        ]);
49
    }
50
51
    /**
52
     * @param array $SelectionCriteria
53
     * @return array
54
     * @throws \Throwable
55
     *
56
     * @see https://tech.yandex.ru/direct/doc/ref-v5/campaigns/delete-docpage/
57
     */
58
    public function delete($SelectionCriteria)
59
    {
60
        return $this->call([
61
            'method' => 'delete',
62
            'params' => [
63
                'SelectionCriteria' => $SelectionCriteria
64
            ]
65
        ]);
66
    }
67
68
    /**
69
     * @param array $SelectionCriteria
70
     * @param array $FieldNames
71
     * @param array $TextCampaignFieldNames
72
     * @param array $MobileAppCampaignFieldNames
73
     * @param array $DynamicTextCampaignFieldNames
74
     * @param array $CpmBannerCampaignFieldNames
75
     * @param array $SmartCampaignFieldNames
76
     * @param array $Page
77
     * @return array
78
     * @throws \Throwable
79
     *
80
     * @see https://tech.yandex.ru/direct/doc/ref-v5/campaigns/get-docpage/
81
     */
82
    public function get(
83
        $SelectionCriteria,
84
        $FieldNames,
85
        $TextCampaignFieldNames = null,
86
        $MobileAppCampaignFieldNames = null,
87
        $DynamicTextCampaignFieldNames = null,
88
        $CpmBannerCampaignFieldNames = null,
89
        $SmartCampaignFieldNames = null,
90
        $Page = null
91
    ) {
92
        $params = compact(get_param_names(__METHOD__));
93
94
        return $this->call([
95
            'method' => 'get',
96
            'params' => $params
97
        ]);
98
    }
99
100
    /**
101
     * @param $SelectionCriteria
102
     * @return array
103
     * @throws \Throwable
104
     *
105
     * @see https://tech.yandex.ru/direct/doc/ref-v5/campaigns/resume-docpage/
106
     */
107
    public function resume($SelectionCriteria)
108
    {
109
        return $this->call([
110
            'method' => 'resume',
111
            'params' => [
112
                'SelectionCriteria' => $SelectionCriteria
113
            ]
114
        ]);
115
    }
116
117
    /**
118
     * @param array $SelectionCriteria
119
     * @return array
120
     * @throws \Throwable
121
     *
122
     * @see https://tech.yandex.ru/direct/doc/ref-v5/campaigns/suspend-docpage/
123
     */
124
    public function suspend($SelectionCriteria)
125
    {
126
        return $this->call([
127
            'method' => 'suspend',
128
            'params' => [
129
                'SelectionCriteria' => $SelectionCriteria
130
            ]
131
        ]);
132
    }
133
134
    /**
135
     * @param array $SelectionCriteria
136
     * @return array
137
     * @throws \Throwable
138
     *
139
     * @see https://tech.yandex.ru/direct/doc/ref-v5/campaigns/unarchive-docpage/
140
     */
141
    public function unarchive($SelectionCriteria)
142
    {
143
        return $this->call([
144
            'method' => 'unarchive',
145
            'params' => [
146
                'SelectionCriteria' => $SelectionCriteria
147
            ]
148
        ]);
149
    }
150
151
    /**
152
     * @param array $Campaigns
153
     * @return array
154
     * @throws \Throwable
155
     *
156
     * @see https://tech.yandex.ru/direct/doc/ref-v5/campaigns/update-docpage/
157
     * @see https://tech.yandex.ru/direct/doc/ref-v5/campaigns/update-text-campaign-docpage/
158
     * @see https://tech.yandex.ru/direct/doc/ref-v5/campaigns/update-dynamic-text-campaign-docpage/
159
     * @see https://tech.yandex.ru/direct/doc/ref-v5/campaigns/update-mobile-app-campaign-docpage/
160
     */
161
    public function update($Campaigns)
162
    {
163
        return $this->call([
164
            'method' => 'update',
165
            'params' => [
166
                'Campaigns' => $Campaigns
167
            ]
168
        ]);
169
    }
170
}
171