Passed
Push — master ( 517bd8...f7cc98 )
by Attila
06:55
created

EnumProxy   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
dl 0
loc 33
rs 10
c 0
b 0
f 0

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