Completed
Branch feature/pre-split (0400ca)
by Anton
03:49
created

RelationsConfig::relationClass()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

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