Completed
Push — master ( eb5db0...0b2361 )
by Lucas
02:07
created

Processor   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 41
Duplicated Lines 9.76 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 3
Bugs 0 Features 1
Metric Value
wmc 4
c 3
b 0
f 1
lcom 0
cbo 0
dl 4
loc 41
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getConfiguration() 0 4 1
A __toString() 0 4 1
A frenchTransactionFormatter() 4 14 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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