RelationsConfig::relationClass()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
/**
3
 * Spiral, Core Components
4
 *
5
 * @author Wolfy-J
6
 */
7
8
namespace Spiral\ORM\Configs;
9
10
use Spiral\Core\InjectableConfig;
11
12
/**
13
 * Defined classes and behaviours for ORM relations.
14
 */
15
class RelationsConfig extends InjectableConfig
16
{
17
    /**
18
     * Configuration section.
19
     */
20
    const CONFIG = 'schemas/relations';
21
22
    /**
23
     * Relation sub classes.
24
     */
25
    const SCHEMA_CLASS = 'schema';
26
    const LOADER_CLASS = 'loader';
27
    const ACCESS_CLASS = 'access';
28
29
    /**
30
     * @var array
31
     */
32
    protected $config = [];
33
34
    /**
35
     * @param string $type
36
     * @param string $section
37
     *
38
     * @return bool
39
     */
40
    public function hasRelation(string $type, string $section = self::SCHEMA_CLASS): bool
41
    {
42
        return isset($this->config[$type][$section]);
43
    }
44
45
    /**
46
     * @param string $type
47
     * @param string $section
48
     *
49
     * @return string
50
     */
51
    public function relationClass(string $type, string $section): string
52
    {
53
        return $this->config[$type][$section];
54
    }
55
}