Completed
Branch feature/split-orm (60a911)
by Anton
03:15
created

MutatorsConfig::getMutators()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

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