MutatorsConfig   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 32
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getMutators() 0 7 2
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
}