Campaigns::get()   A
last analyzed

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