Completed
Push — master ( fbe46c...fa1c37 )
by Max
02:21
created

SantaCruzBankParser   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 31
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A parse() 0 17 2
1
<?php
2
3
namespace MidasSoft\DominicanBankParser\Parsers;
4
5
use MidasSoft\DominicanBankParser\Collections\DepositCollection;
6
use MidasSoft\DominicanBankParser\Deposit;
7
use MidasSoft\DominicanBankParser\Files\CSV;
8
use MidasSoft\DominicanBankParser\Files\AbstractFile;
9
use MidasSoft\DominicanBankParser\Validators\SantaCruzValidator;
10
11
class SantaCruzBankParser extends AbstractParser
12
{
13
    /**
14
     * Eliminates unnecesary values into
15
     * a Santa Cruz bank file and convert it
16
     * to array.
17
     *
18
     * @param \MidasSoft\DominicanBankParser\Files\CSV $file
19
     *
20
     * @throws \MidasSoft\DominicanBankParser\Exceptions\InvalidArgumentException
21
     * @throws \MidasSoft\DominicanBankParser\Exceptions\EmptyFileException
22
     *
23
     * @return array
24
     */
25 3
    public function parse(AbstractFile $file)
26
    {
27 3
        $collection = new DepositCollection();
28 3
        $fileArray = array_slice($file->toArray(), 7);
29
30
        array_walk($fileArray, function ($line, $key) use (&$collection) {
0 ignored issues
show
Unused Code introduced by
The parameter $key is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

30
        array_walk($fileArray, function ($line, /** @scrutinizer ignore-unused */ $key) use (&$collection) {

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

Loading history...
31 2
            if (!SantaCruzValidator::validate($line)) {
32 2
                return;
33
            }
34
35 2
            $collection->push(new Deposit($line[3], $line[0], $line[1], $line[1]));
36 3
        });
37
38 3
        $this->failIfParsedFileIsEmpty($collection);
39 2
        $this->cache($collection);
40
41 2
        return $collection;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $collection returns the type MidasSoft\DominicanBankP...tions\DepositCollection which is incompatible with the documented return type array.
Loading history...
42
    }
43
}
44