ConstReader   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 11
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 3
dl 0
loc 11
rs 10
c 0
b 0
f 0

1 Method

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