WithCastingMethods   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 13
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A castValueOut() 0 3 1
A castValueIn() 0 3 1
1
<?php
2
declare(strict_types=1);
3
4
namespace JDecool\Test\Doctrine\Enum;
5
6
use MabeEnum\Enum;
7
use function str_replace;
8
use function strtolower;
9
use function strtoupper;
10
11
/**
12
 * Class WithCastingMethods
13
 * @author
14
 * @link
15
 *
16
 * @method static WithCastingMethods FOO()
17
 * @method static WithCastingMethods BAR()
18
 */
19
class WithCastingMethods extends Enum
20
{
21
    public const FOO = 'foo_value';
22
    public const BAR = 'bar_value';
23
24
    public static function castValueIn($value)
25
    {
26
        return strtolower(str_replace(' ', '_', $value));
27
    }
28
29
    public static function castValueOut(self $value)
30
    {
31
        return strtoupper(str_replace('_', ' ', $value->getValue()));
32
    }
33
}
34