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

EnumProxy::guessContract()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
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