MutatorsConfig::getMutators()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
1
<?php
2
/**
3
 * Spiral Framework.
4
 *
5
 * @license MIT
6
 * @author  Anton Titov (Wolfy-J)
7
 */
8
9
namespace Spiral\ORM\Configs;
10
11
use Spiral\Core\InjectableConfig;
12
use Spiral\Core\Traits\Config\AliasTrait;
13
14
/**
15
 *  Provides set of rules and aliases for automatic mutations for Record fields.
16
 */
17
class MutatorsConfig extends InjectableConfig
18
{
19
    use AliasTrait;
20
21
    /**
22
     * Configuration section.
23
     */
24
    const CONFIG = 'schemas/records';
25
26
    /**
27
     * @var array
28
     */
29
    protected $config = [
30
        'aliases'  => [],
31
        'mutators' => []
32
    ];
33
34
    /**
35
     * Get list of mutators associated with given field type.
36
     *
37
     * @param string $type
38
     *
39
     * @return array
40
     */
41
    public function getMutators(string $type): array
42
    {
43
        $type = $this->resolveAlias($type);
44
        $mutators = $this->config['mutators'];
45
46
        return isset($mutators[$type]) ? $mutators[$type] : [];
47
    }
48
}
49