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

Ads::get()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 23

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 14
dl 0
loc 23
rs 9.552
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
/**
3
 * @author Dmitry Gladyshev <[email protected]>
4
 * @date 26/08/2016 13:51
5
 */
6
7
namespace Gladyshev\Yandex\Direct\Service;
8
9
use ReflectionException;
10
11
12
use function Gladyshev\Yandex\Direct\get_param_names;
13
14
/**
15
 * Class Ads
16
 * @package Gladyshev\Yandex\Direct\Service
17
 */
18
final class Ads extends \Gladyshev\Yandex\Direct\AbstractService
19
{
20
    /**
21
     * @param $Ads
22
     * @return array
23
     * @throws \Throwable
24
     *
25
     * @see https://tech.yandex.ru/direct/doc/ref-v5/ads/add-docpage/
26
     */
27
    public function add($Ads)
28
    {
29
        return $this->call([
30
            'method' => 'add',
31
            'params' => [
32
                'Ads' => $Ads
33
            ]
34
        ]);
35
    }
36
37
    /**
38
     * @param $Ads
39
     * @return array
40
     * @throws \Throwable
41
     *
42
     * @see https://tech.yandex.ru/direct/doc/ref-v5/ads/update-docpage/
43
     */
44
    public function update($Ads)
45
    {
46
        return $this->call([
47
            'method' => 'update',
48
            'params' => [
49
                'Ads' => $Ads
50
            ]
51
        ]);
52
    }
53
54
    /**
55
     * @param $SelectionCriteria
56
     * @return array
57
     * @throws \Throwable
58
     *
59
     * @see https://tech.yandex.ru/direct/doc/ref-v5/ads/delete-docpage/
60
     */
61
    public function delete($SelectionCriteria)
62
    {
63
        return $this->call([
64
            'method' => 'delete',
65
            'params' => [
66
                'SelectionCriteria' => $SelectionCriteria
67
            ]
68
        ]);
69
    }
70
71
    /**
72
     * @param $SelectionCriteria
73
     * @return array
74
     * @throws \Throwable
75
     *
76
     * https://tech.yandex.ru/direct/doc/ref-v5/ads/suspend-docpage/
77
     */
78
    public function suspend($SelectionCriteria)
79
    {
80
        return $this->call([
81
            'method' => 'suspend',
82
            'params' => [
83
                'SelectionCriteria' => $SelectionCriteria
84
            ]
85
        ]);
86
    }
87
88
    /**
89
     * @param $SelectionCriteria
90
     * @return array
91
     * @throws \Throwable
92
     *
93
     * https://tech.yandex.ru/direct/doc/ref-v5/ads/resume-docpage/
94
     */
95
    public function resume($SelectionCriteria)
96
    {
97
        return $this->call([
98
            'method' => 'resume',
99
            'params' => [
100
                'SelectionCriteria' => $SelectionCriteria
101
            ]
102
        ]);
103
    }
104
105
    /**
106
     * @param $SelectionCriteria
107
     * @return array
108
     * @throws \Throwable
109
     *
110
     * https://tech.yandex.ru/direct/doc/ref-v5/ads/archive-docpage/
111
     */
112
    public function archive($SelectionCriteria)
113
    {
114
        return $this->call([
115
            'method' => 'archive',
116
            'params' => [
117
                'SelectionCriteria' => $SelectionCriteria
118
            ]
119
        ]);
120
    }
121
122
    /**
123
     * @param $SelectionCriteria
124
     * @return array
125
     * @throws \Throwable
126
     *
127
     * https://tech.yandex.ru/direct/doc/ref-v5/ads/unarchive-docpage/
128
     */
129
    public function unarchive($SelectionCriteria)
130
    {
131
        return $this->call([
132
            'method' => 'unarchive',
133
            'params' => [
134
                'SelectionCriteria' => $SelectionCriteria
135
            ]
136
        ]);
137
    }
138
139
    /**
140
     * @param $SelectionCriteria
141
     * @return array
142
     * @throws \Throwable
143
     *
144
     * https://tech.yandex.ru/direct/doc/ref-v5/ads/moderate-docpage/
145
     */
146
    public function moderate($SelectionCriteria)
147
    {
148
        return $this->call([
149
            'method' => 'moderate',
150
            'params' => [
151
                'SelectionCriteria' => $SelectionCriteria
152
            ]
153
        ]);
154
    }
155
156
157
    /**
158
     * Возвращает параметры объявлений, отвечающих заданным критериям.
159
     *
160
     * @param array $SelectionCriteria
161
     * @param array $FieldNames
162
     * @param array $TextAdFieldNames
163
     * @param array $MobileAppAdFieldNames
164
     * @param array $DynamicTextAdFieldNames
165
     * @param array $TextImageAdFieldNames
166
     * @param array $MobileAppImageAdFieldNames
167
     * @param array $TextAdBuilderAdFieldNames
168
     * @param array $MobileAppAdBuilderAdFieldNames
169
     * @param array $CpcVideoAdBuilderAdFieldNames
170
     * @param array $CpmBannerAdBuilderAdFieldNames
171
     * @param array $CpmVideoAdBuilderAdFieldNames
172
     * @param array $SmartAdBuilderAdFieldNames
173
     * @param array $Page
174
     * @return array
175
     * @throws \Throwable
176
     * @throws ReflectionException
177
     *
178
     * @see https://tech.yandex.ru/direct/doc/ref-v5/ads/get-docpage/
179
     */
180
    public function get(
181
        $SelectionCriteria,
182
        $FieldNames,
183
        $TextAdFieldNames = null,
184
        $MobileAppAdFieldNames = null,
185
        $DynamicTextAdFieldNames = null,
186
        $TextImageAdFieldNames = null,
187
        $MobileAppImageAdFieldNames = null,
188
        $TextAdBuilderAdFieldNames = null,
189
        $MobileAppAdBuilderAdFieldNames = null,
190
        $CpcVideoAdBuilderAdFieldNames = null,
191
        $CpmBannerAdBuilderAdFieldNames = null,
192
        $CpmVideoAdBuilderAdFieldNames = null,
193
        $SmartAdBuilderAdFieldNames = null,
194
        $Page = null
195
    ) {
196
        $params = compact(get_param_names(__METHOD__));
197
198
        return $this->call([
199
            'method' => 'get',
200
            'params' => $params
201
        ]);
202
    }
203
}
204