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
3
declare(strict_types=1);
4
5
namespace Acelaya\Test\Doctrine\Enum;
6
7
use MyCLabs\Enum\Enum;
8
9
use function str_replace;
10
use function strtolower;
11
use function strtoupper;
12
13
/**
14
 * Class WithCastingMethods
15
 * @author
16
 * @link
17
 *
18
 * @method static WithCastingMethods FOO()
19
 * @method static WithCastingMethods BAR()
20
 */
21
class WithCastingMethods extends Enum
22
{
23
    public const FOO = 'foo_value';
24
    public const BAR = 'bar_value';
25
26
    public static function castValueIn($value)
27
    {
28
        return strtolower(str_replace(' ', '_', $value));
29
    }
30
31
    public static function castValueOut(self $value)
32
    {
33
        return strtoupper(str_replace('_', ' ', (string) $value));
34
    }
35
}
36