Reports::get()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 11
dl 0
loc 19
rs 9.6333
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
namespace Yandex\Direct\Service;
4
5
use Yandex\Direct\Exception\Exception;
6
use Yandex\Direct\Service;
7
use function Yandex\Direct\get_param_names;
8
9
/**
10
 * Class Reports
11
 *
12
 * @author Dmitry Gladyshev <[email protected]>
13
 */
14
final class Reports extends Service
15
{
16
    /**
17
     * Спецификация отчета.
18
     *
19
     * @param $SelectionCriteria
20
     * @param $Goals
21
     * @param $FieldNames
22
     * @param $ReportName
23
     * @param $ReportType
24
     * @param $DateRangeType
25
     * @param $Format
26
     * @param $IncludeVAT
27
     * @param $IncludeDiscount
28
     * @param $Page
29
     * @param $OrderBy
30
     * @return string
31
     *
32
     * @throws Exception
33
     * @throws \ReflectionException
34
     *
35
     * @see https://tech.yandex.ru/direct/doc/reports/spec-docpage/
36
     */
37
    public function get(
38
        $SelectionCriteria,
39
        $FieldNames,
40
        $ReportName,
41
        $ReportType,
42
        $DateRangeType,
43
        $Page = null,
44
        $OrderBy = null,
45
        $IncludeVAT = 'YES',
46
        $IncludeDiscount = 'YES',
47
        $Format = 'TSV',
48
        $Goals = []
49
    ) {
50
        $params = compact(get_param_names(__METHOD__));
51
52
        return $this->request([
53
            'params' => $params
54
        ]);
55
    }
56
57
    /**
58
     * Режим формирования отчета: online, offline или auto.
59
     * Отсутствие заголовка эквивалентно значению auto.
60
     *
61
     * @param $processingMode
62
     * @return $this
63
     * @see https://tech.yandex.ru/direct/doc/reports/headers-docpage/
64
     */
65
    public function setProcessingMode($processingMode)
66
    {
67
        $this->headers['processingMode'] = $processingMode;
68
        return $this;
69
    }
70
71
    /**
72
     * Если заголовок указан, денежные значения в отчете возвращаются в валюте с точностью до двух знаков после
73
     * запятой. Если не указан, денежные значения возвращаются в виде целых чисел — сумм в валюте,
74
     * умноженных на 1 000 000.
75
     *
76
     * @param $returnMoneyInMicros
77
     * @return $this
78
     * @see https://tech.yandex.ru/direct/doc/reports/headers-docpage/
79
     */
80
    public function setReturnMoneyInMicros($returnMoneyInMicros)
81
    {
82
        if (is_numeric($returnMoneyInMicros) || is_bool($returnMoneyInMicros)) {
83
            $returnMoneyInMicros = $returnMoneyInMicros ? 'true' : 'false';
84
        }
85
        $this->headers['returnMoneyInMicros'] = $returnMoneyInMicros;
86
        return $this;
87
    }
88
89
    /**
90
     * Не выводить в отчете строку с названием отчета и диапазоном дат.
91
     * @return $this
92
     * @see https://tech.yandex.ru/direct/doc/reports/headers-docpage/
93
     */
94
    public function setSkipReportHeader()
95
    {
96
        $this->headers['skipReportHeader'] = 'true';
97
        return $this;
98
    }
99
100
    /**
101
     * Не выводить в отчете строку с названиями полей.
102
     *
103
     * @return $this
104
     * @see https://tech.yandex.ru/direct/doc/reports/headers-docpage/
105
     */
106
    public function setSkipColumnHeader()
107
    {
108
        $this->headers['skipColumnHeader'] = 'true';
109
        return $this;
110
    }
111
112
    /**
113
     * Не выводить в отчете строку с количеством строк статистики.
114
     *
115
     * @see https://tech.yandex.ru/direct/doc/reports/headers-docpage/
116
     */
117
    public function setSkipReportSummary()
118
    {
119
        $this->headers['skipReportSummary'] = 'true';
120
        return $this;
121
    }
122
}
123