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

MutatorsConfig::getMutators()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 7
Ratio 100 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 1
dl 7
loc 7
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 * Spiral Framework.
4
 *
5
 * @license MIT
6
 * @author  Anton Titov (Wolfy-J)
7
 */
8
namespace Spiral\ORM\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 Record fields.
15
 */
16 View Code Duplication
class MutatorsConfig extends InjectableConfig
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
17
{
18
    use AliasTrait;
19
20
    /**
21
     * Configuration section.
22
     */
23
    const CONFIG = 'schemas/records';
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
}
48