AmountFilter   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 4
Bugs 1 Features 0
Metric Value
wmc 4
c 4
b 1
f 0
lcom 0
cbo 2
dl 0
loc 18
ccs 4
cts 4
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A filter() 0 8 4
1
<?php
2
3
namespace ZFBrasil\DoctrineMoneyModule\Filter;
4
5
use Money\InvalidArgumentException;
6
use Money\Money;
7
use Zend\Filter\AbstractFilter;
8
9
/**
10
 * @author Gabriel Schmitt <[email protected]>
11
 * @license MIT
12
 */
13
class AmountFilter extends AbstractFilter
14
{
15
    /**
16
     * {@inheritdoc}
17
     *
18
     * @throws InvalidArgumentException
19
     *
20
     * @return int|null
21
     */
22 5
    public function filter($value)
23
    {
24 5
        if (null === $value || (is_string($value) && strlen($value) === 0)) {
25 2
            return null;
26
        }
27
28 4
        return Money::stringToUnits($value);
29
    }
30
}
31