ReservasValidator   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Test Coverage

Coverage 80%

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 40
ccs 8
cts 10
cp 0.8
rs 10
c 0
b 0
f 0
wmc 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A validate() 0 11 3
A amountIsWithdrawWithoutNotebook() 0 3 1
A amountIsZero() 0 3 1
1
<?php
2
3
namespace MidasSoft\DominicanBankParser\Validators;
4
5
use MidasSoft\DominicanBankParser\Interfaces\ValidatorInterface;
6
7
class ReservasValidator implements ValidatorInterface
8
{
9
    /**
10
     * {@inheritdoc}
11
     */
12 2
    public static function validate(array $deposit)
13
    {
14 2
        if (self::amountIsZero(trim($deposit[5]))) {
15
            return false;
16
        }
17
18 2
        if (self::amountIsWithdrawWithoutNotebook($deposit[2])) {
19
            return false;
20
        }
21
22 2
        return true;
23
    }
24
25
    /**
26
     * Checks if amount is zero.
27
     *
28
     * @param string $amount
29
     *
30
     * @return bool
31
     */
32 2
    private static function amountIsZero($amount)
33
    {
34 2
        return $amount == 0;
35
    }
36
37
    /**
38
     * Checks if the deposit is a withdraw.
39
     *
40
     * @param string $description
41
     *
42
     * @return bool
43
     */
44 2
    private static function amountIsWithdrawWithoutNotebook($description)
45
    {
46 2
        return $description == 'Retiro de ahorros sin libreta';
47
    }
48
}
49