File400::mutateDetailBranch()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
c 0
b 0
f 0
rs 9.4285
cc 1
eloc 5
nc 1
nop 3
1
<?php
2
3
namespace SmartCNAB\Services\Remittances\Banks\BancoDoBrasil;
4
5
use SmartCNAB\Support\File\Remittance;
6
7
/**
8
 * Class for Banco do Brasil remittance CNAB 400 layout.
9
 */
10
class File400 extends Remittance
11
{
12
    /**
13
     * File schema file.
14
     *
15
     * @var string
16
     */
17
    protected $schemaFile = '/schemas/400.json';
18
19
    /**
20
     * Mutates an account on detail.
21
     *
22
     * @param  mixed  $value
23
     * @param  array  $data
24
     * @param  array  $meta
25
     * @return mixed
26
     */
27
    protected function mutateDetailAccount(
28
        $value,
29
        array $data = [],
30
        array $meta = []
31
    ) {
32
        return $this->mutateHeaderAccount($value, $data, $meta);
0 ignored issues
show
Unused Code introduced by
The call to File400::mutateHeaderAccount() has too many arguments starting with $meta.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
33
    }
34
35
    /**
36
     * Mutates an account DV on detail.
37
     *
38
     * @param  mixed  $value
39
     * @param  array  $data
40
     * @param  array  $meta
41
     * @return mixed
42
     */
43
    protected function mutateDetailAccountDv(
44
        $value,
45
        array $data = [],
46
        array $meta = []
47
    ) {
48
        return $this->mutateHeaderAccountDv($value, $data, $meta);
0 ignored issues
show
Unused Code introduced by
The call to File400::mutateHeaderAccountDv() has too many arguments starting with $meta.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
49
    }
50
51
    /**
52
     * Mutates a branch on detail.
53
     *
54
     * @param  mixed  $value
55
     * @param  array  $data
56
     * @param  array  $meta
57
     * @return mixed
58
     */
59
    protected function mutateDetailBranch(
60
        $value,
61
        array $data = [],
62
        array $meta = []
63
    ) {
64
        return $this->mutateHeaderBranch($value, $data, $meta);
0 ignored issues
show
Unused Code introduced by
The call to File400::mutateHeaderBranch() has too many arguments starting with $meta.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
65
    }
66
67
    /**
68
     * Mutates a branch DV on detail.
69
     *
70
     * @param  mixed  $value
71
     * @param  array  $data
72
     * @param  array  $meta
73
     * @return mixed
74
     */
75
    protected function mutateDetailBranchDv(
76
        $value,
77
        array $data = [],
78
        array $meta = []
79
    ) {
80
        return $this->mutateHeaderBranchDv($value, $data, $meta);
0 ignored issues
show
Unused Code introduced by
The call to File400::mutateHeaderBranchDv() has too many arguments starting with $meta.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
81
    }
82
83
    /**
84
     * Mutates a company document type.
85
     *
86
     * @param  mixed  $value
87
     * @param  array  $data
88
     * @return mixed
89
     */
90
    protected function mutateDetailCompanyDocumentType(
91
        $value,
0 ignored issues
show
Unused Code introduced by
The parameter $value is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
92
        array $data = []
93
    ) {
94
        return strlen($data['companyDocument']) === 14 ? 2 : 1;
95
    }
96
97
    /**
98
     * Mutates a discount to date.
99
     *
100
     * @param  mixed  $value
101
     * @param  array  $data
102
     * @return mixed
103
     */
104
    protected function mutateDetailDiscountTo(
105
        $value,
106
        array $data = []
107
    ) {
108
        return $value ?: $data['expiration'];
109
    }
110
111
    /**
112
     * Mutates a document type.
113
     *
114
     * @param  mixed  $value
115
     * @param  array  $data
116
     * @return mixed
117
     */
118
    protected function mutateDetailDocumentType(
119
        $value,
0 ignored issues
show
Unused Code introduced by
The parameter $value is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
120
        array $data = []
121
    ) {
122
        return strlen($data['document']) === 14 ? 2 : 1;
123
    }
124
125
    /**
126
     * Mutates an account on header.
127
     *
128
     * @param  mixed  $value
129
     * @param  array  $data
130
     * @return mixed
131
     */
132
    protected function mutateHeaderAccount(
133
        $value,
134
        array $data = []
135
    ) {
136
        if (empty($data['account'])) return $value;
137
138
        return $value ?: $data['account'];
139
    }
140
141
    /**
142
     * Mutates an account DV on header.
143
     *
144
     * @param  mixed  $value
145
     * @param  array  $data
146
     * @return mixed
147
     */
148
    protected function mutateHeaderAccountDv(
149
        $value,
150
        array $data = []
151
    ) {
152
        if (empty($data['account'])) return $value;
153
154
        return $value ?: $data['accountDv'];
155
    }
156
157
    /**
158
     * Mutates a branch on header.
159
     *
160
     * @param  mixed  $value
161
     * @param  array  $data
162
     * @return mixed
163
     */
164
    protected function mutateHeaderBranch(
165
        $value,
166
        array $data = []
167
    ) {
168
        if (empty($data['branch'])) return $value;
169
170
        return $value ?: $data['branch'];
171
    }
172
173
    /**
174
     * Mutates a branch DV on header.
175
     *
176
     * @param  mixed  $value
177
     * @param  array  $data
178
     * @return mixed
179
     */
180
    protected function mutateHeaderBranchDv(
181
        $value,
182
        array $data = []
183
    ) {
184
        if (empty($data['branch'])) return $value;
185
186
        return $value ?: $data['branchDv'];
187
    }
188
}
189