CurrencyType::getName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 2
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