ConstReader::fromConst()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
1
<?php
2
3
namespace evelikto\di\reader;
4
5
/** Reads config constant $name which can also be handled as a dependency */
6
trait ConstReader
7
{
8
    /**
9
     * Resolves dependency from a const config value, returns null if no such const exists.
10
     *
11
     * @param   string      $name  Name of the constant
12
     * @return  mixed|null         Constant value or null if no such const
13
     */
14
    protected function fromConst(string $name) {
15
        $cname = $this->configClassName.'::'.$name;
16
        return defined($cname) ? constant($cname) : null;
17
    }
18
}