File400::mutateDetailPortfolio()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 3
eloc 2
nc 4
nop 1
1
<?php
2
3
namespace SmartCNAB\Services\Remittances\Banks\Caixa;
4
5
use SmartCNAB\Support\Bank\Caixa;
6
use SmartCNAB\Support\File\Remittance;
7
8
/**
9
 * Class for Caixa remittance CNAB 400 layout.
10
 */
11
class File400 extends Remittance
12
{
13
    /**
14
     * File schema file.
15
     *
16
     * @var string
17
     */
18
    protected $schemaFile = '/schemas/400.json';
19
20
    /**
21
     * Mutates a company document type.
22
     *
23
     * @param  mixed  $value
24
     * @param  array  $data
25
     * @return mixed
26
     */
27
    protected function mutateDetailCompanyDocumentType(
28
        $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...
29
        array $data = []
30
    ) {
31
        return strlen($data['companyDocument']) === 14 ? 2 : 1;
32
    }
33
34
    /**
35
     * Mutates a discount to date.
36
     *
37
     * @param  mixed  $value
38
     * @param  array  $data
39
     * @return mixed
40
     */
41
    protected function mutateDetailDiscountTo(
42
        $value,
43
        array $data = []
44
    ) {
45
        return $value ?: $data['expiration'];
46
    }
47
48
    /**
49
     * Mutates a document type.
50
     *
51
     * @param  mixed  $value
52
     * @param  array  $data
53
     * @return mixed
54
     */
55
    protected function mutateDetailDocumentType(
56
        $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...
57
        array $data = []
58
    ) {
59
        return strlen($data['document']) === 14 ? 2 : 1;
60
    }
61
62
    /**
63
     * Format instruction1 according occurrence code.
64
     *
65
     * @param  mixed  $value
66
     * @param  array  $data
67
     * @return mixed
68
     */
69
    protected function mutateDetailInstruction1(
70
        $value,
71
        array $data = []
72
    ) {
73
        if ($data['occurrenceCode'] == 11) return Caixa::INSTRUCTION_PROTEST;
74
75
        if ($data['occurrenceCode'] == 12) return Caixa::INSTRUCTION_DEVOLUTION;
76
77
        return $value;
78
    }
79
80
    /**
81
     * Mutates a late interest date.
82
     *
83
     * @param  mixed  $value
84
     * @param  array  $data
85
     * @return mixed
86
     */
87
    protected function mutateDetailLateInterestDate(
88
        $value,
89
        array $data = []
90
    ) {
91
        $returnValue = $value == '' && $data['occurrenceCode'] == 9;
92
93
        if ($returnValue) return $value;
94
95
        return $value ?: $data['expiration']->add(new \DateInterval('P1D'));
96
    }
97
98
    /**
99
     * Mutates a portfolio.
100
     *
101
     * @param  mixed  $value
102
     * @return mixed
103
     */
104
    protected function mutateDetailPortfolio($value)
105
    {
106
        return ($value === 'SR' ? 2 : ($value === 'RG' ? 1 : $value));
107
    }
108
}
109