EnumProxy   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 3
eloc 6
c 2
b 1
f 0
dl 0
loc 33
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A enumClass() 0 5 1
A guessContract() 0 4 1
A targetClass() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * Contains the EnumProxy class.
7
 *
8
 * @copyright   Copyright (c) 2017 Attila Fulop
9
 * @author      Attila Fulop
10
 * @license     MIT
11
 * @since       2017-05-24
12
 *
13
 */
14
15
namespace Konekt\Concord\Proxies;
16
17
class EnumProxy extends BaseProxy
18
{
19
    /**
20
     * Returns the real enum class FQCN
21
     *
22
     * @return string
23
     */
24
    public static function enumClass()
25
    {
26
        $instance = static::getInstance();
27
28
        return $instance->targetClass();
29
    }
30
31
    /**
32
     * @inheritDoc
33
     */
34
    protected function targetClass(): string
35
    {
36
        return $this->concord->enum($this->contract);
37
    }
38
39
    /**
40
     * Tries guessing the associated contract class for an actual proxy class
41
     * Depending on the convention used by concord, the default pattern is
42
     * 'UserTypeProxy' -> enum == 'UserType' -> '../Contracts/UserType'
43
     *
44
     * @return string
45
     */
46
    protected function guessContract()
47
    {
48
        return $this->concord->getConvention()->contractForEnum(
49
            $this->concord->getConvention()->enumForProxy(static::class)
50
        );
51
    }
52
}
53