SgProProcessor   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 5
Bugs 1 Features 1
Metric Value
wmc 2
c 5
b 1
f 1
lcom 0
cbo 1
dl 0
loc 49
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B format() 0 29 2
1
<?php
2
3
namespace Kasifi\PdfParserBundle\Processor;
4
5
use Doctrine\Common\Collections\ArrayCollection;
6
7
/**
8
 * Class SgProProcessor.
9
 */
10
class SgProProcessor extends Processor implements ProcessorInterface
11
{
12
    protected $configuration = [
13
        'id' => 'sg_pro',
14
        'name' => 'Société Générale - Compte courant professionnel',
15
        'startConditions' => ['/Date\s+Valeur\s+Nature de l\'opération/'],
16
        'endConditions' => [
17
            '/1 Depuis l\'étranger/', '/N° d\'adhérent JAZZ Pro/', '/Société Générale\s+552 120 222 RCS Paris/',
18
        ],
19
        'rowMergeColumnTokens' => [0],
20
        'rowSkipConditions' => ['SOLDE PRÉCÉDENT AU', 'TOTAUX DES MOUVEMENTS', 'RA4-01K', 'NOUVEAU SOLDE AU'],
21
        'rowsToSkip' => [0],
22
    ];
23
24
    /**
25
     * @param ArrayCollection $data
26
     *
27
     * @return ArrayCollection
28
     */
29
    public function format(ArrayCollection $data)
30
    {
31
        $data = $data->map(function ($item) {
32
            // Date
33
            $dateRaw = $item[0];
34
            $date = new \DateTime();
35
            $date->setDate((int) substr($dateRaw, 6, 4), (int) substr($dateRaw, 3, 2), (int) substr($dateRaw, 0, 2));
36
            $date->setTime(12, 0, 0);
37
38
            // Value Date
39
            $dateRaw = $item[1];
40
            $valueDate = new \DateTime();
41
            $valueDate->setDate((int) substr($dateRaw, 6, 4), (int) substr($dateRaw, 3, 2), (int) substr($dateRaw, 0, 2));
42
            $valueDate->setTime(12, 0, 0);
43
44
            // Transaction
45
            $transaction = $this->frenchTransactionFormatter($item[3], isset($item[4]) ? $item[4] : null);
46
47
            return [
48
                'date' => $date,
49
                'value_date' => $valueDate,
50
                'label' => $item[2],
51
                'value' => $transaction['value'],
52
                'debit' => $transaction['debit'],
53
            ];
54
        });
55
56
        return $data;
57
    }
58
}
59