Completed
Branch master (0b2361)
by Lucas
04:00 queued 02:07
created

Processor::frenchTransactionFormatter()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 10

Duplication

Lines 4
Ratio 28.57 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 4
loc 14
rs 9.4285
cc 2
eloc 10
nc 2
nop 2
1
<?php
2
3
namespace Kasifi\PdfParserBundle\Processor;
4
5
/**
6
 * Class Processor.
7
 */
8
abstract class Processor
9
{
10
    /**
11
     * @var array
12
     */
13
    protected $configuration;
14
15
    /**
16
     * @return array
17
     */
18
    public function getConfiguration()
19
    {
20
        return $this->configuration;
21
    }
22
23
    public function __toString()
24
    {
25
        return (string) $this->configuration['name'];
26
    }
27
28
    /**
29
     * @param string $debitRaw
30
     * @param string $creditRaw
31
     *
32
     * @return array
33
     */
34
    public function frenchTransactionFormatter($debitRaw, $creditRaw)
35
    {
36
        if (strlen($debitRaw)) {
37
            $value = abs((float) str_replace(',', '.', str_replace(' ', '', $debitRaw)));
38
            $debit = true;
39 View Code Duplication
        } else {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
40
            $value = (float) str_replace(',', '.', str_replace(' ', '', $creditRaw));
41
            $debit = false;
42
        }
43
        return [
44
            'value' => $value,
45
            'debit' => $debit,
46
        ];
47
    }
48
}
49