CurrencyType   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 0%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getName() 0 4 1
A convertToPHPValue() 0 8 3
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