CurrencyType::convertToPHPValue()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
ccs 0
cts 4
cp 0
rs 9.4285
cc 3
eloc 4
nc 2
nop 2
crap 12
1
<?php
2
3
namespace ZFBrasil\DoctrineMoneyModule\DBAL\Types;
4
5
use Doctrine\DBAL\Types\StringType;
6
use Money\Currency;
7
use Doctrine\DBAL\Platforms\AbstractPlatform;
8
9
/**
10
 * @author Fábio Carneiro <[email protected]>
11
 * @license MIT
12
 */
13
class CurrencyType extends StringType
14
{
15
    const NAME = 'currency';
16
17
    /**
18
     * {@inheritdoc}
19
     */
20
    public function getName()
21
    {
22
        return self::NAME;
23
    }
24
25
    /**
26
     * {@inheritdoc}
27
     */
28
    public function convertToPHPValue($value, AbstractPlatform $platform)
29
    {
30
        if ($value === null || $value instanceof Currency) {
31
            return $value;
32
        }
33
34
        return new Currency($value);
35
    }
36
}
37