BidModifiers::get()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 9
dl 0
loc 18
rs 9.6666
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 29/08/2016 12:33
5
 */
6
7
namespace Yandex\Direct\Service;
8
9
use Yandex\Direct\Exception\ErrorResponseException;
10
use Yandex\Direct\Exception\Exception;
11
use Yandex\Direct\Service;
12
use function Yandex\Direct\get_param_names;
13
14
/**
15
 * Class BidModifiers
16
 * @package Yandex\Direct\Service
17
 */
18
final class BidModifiers extends Service
19
{
20
    /**
21
     * Создает корректировки ставок.
22
     *
23
     * @param $BidModifiers
24
     * @return array
25
     * @throws Exception
26
     *
27
     * @see https://tech.yandex.ru/direct/doc/ref-v5/bidmodifiers/add-docpage/
28
     */
29
    public function add($BidModifiers)
30
    {
31
        return $this->request([
32
            'method' => 'add',
33
            'params' => [
34
                'BidModifiers' => $BidModifiers
35
            ]
36
        ]);
37
    }
38
39
    /**
40
     * Удаляет корректировки ставок.
41
     *
42
     * @param $SelectionCriteria
43
     * @return array
44
     * @throws Exception
45
     *
46
     * @see https://tech.yandex.ru/direct/doc/ref-v5/bidmodifiers/delete-docpage/
47
     */
48
    public function delete($SelectionCriteria)
49
    {
50
        return $this->request([
51
            'method' => 'delete',
52
            'params' => [
53
                'SelectionCriteria' => $SelectionCriteria
54
            ]
55
        ]);
56
    }
57
58
    /**
59
     * Возвращает параметры корректировок, отвечающих заданным критериям.
60
     *
61
     * @param array $SelectionCriteria
62
     * @param array $FieldNames
63
     * @param array $MobileAdjustmentFieldNames
64
     * @param array $DemographicsAdjustmentFieldNames
65
     * @param array $RetargetingAdjustmentFieldNames
66
     * @param array $RegionalAdjustmentFieldNames
67
     * @param array $VideoAdjustmentFieldNames
68
     * @param array $SmartAdAdjustmentFieldNames
69
     * @param array $Page
70
     *
71
     * @return array
72
     *
73
     * @throws Exception
74
     * @throws \ReflectionException
75
     * @throws ErrorResponseException
76
     *
77
     * @see https://tech.yandex.ru/direct/doc/ref-v5/bidmodifiers/get-docpage/
78
     */
79
    public function get(
80
        $SelectionCriteria,
81
        $FieldNames,
82
        $MobileAdjustmentFieldNames = null,
83
        $DemographicsAdjustmentFieldNames = null,
84
        $RetargetingAdjustmentFieldNames = null,
85
        $RegionalAdjustmentFieldNames = null,
86
        $VideoAdjustmentFieldNames = null,
87
        $SmartAdAdjustmentFieldNames = null,
88
        $Page = null
89
    ) {
90
        $params = compact(get_param_names(__METHOD__));
91
92
        return $this->request([
93
            'method' => 'get',
94
            'params' => $params
95
        ]);
96
    }
97
98
    /**
99
     * Изменяет значения коэффициентов в корректировках ставок.
100
     *
101
     * @param $BidModifiers
102
     * @return array
103
     * @throws Exception
104
     *
105
     * @see https://tech.yandex.ru/direct/doc/ref-v5/bidmodifiers/set-docpage/
106
     */
107
    public function setAuto($BidModifiers)
108
    {
109
        return $this->request([
110
            'method' => 'setAuto',
111
            'params' => [
112
                'BidModifiers' => $BidModifiers
113
            ]
114
        ]);
115
    }
116
117
    /**
118
     * Включает/выключает набор корректировок.
119
     *
120
     * @param $BidModifierToggleItems
121
     * @return array
122
     * @throws Exception
123
     *
124
     * @see https://tech.yandex.ru/direct/doc/ref-v5/bidmodifiers/toggle-docpage/
125
     */
126
    public function toggle($BidModifierToggleItems)
127
    {
128
        return $this->request([
129
            'method' => 'toggle',
130
            'params' => [
131
                'BidModifierToggleItems' => $BidModifierToggleItems
132
            ]
133
        ]);
134
    }
135
}
136