MutatorsConfig::getMutators()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

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