ConfigInterpolatorTrait   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 27
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getInterpolator() 0 7 2
A interpolate() 0 4 1
A mustInterpolate() 0 4 1
1
<?php
2
namespace Consolidation\Config\Util;
3
4
use Consolidation\Config\Config;
5
use Consolidation\Config\ConfigInterface;
6
7
/**
8
 * Provides configuration objects with an 'interpolate' method
9
 * that may be used to inject config values into tokens embedded
10
 * in strings..
11
 */
12
trait ConfigInterpolatorTrait
13
{
14
    protected $interpolator;
15
16
    protected function getInterpolator()
17
    {
18
        if (!isset($this->interpolator)) {
19
            $this->interpolator = new Interpolator();
20
        }
21
        return $this->interpolator;
22
    }
23
    /**
24
     * @inheritdoc
25
     */
26
    public function interpolate($message, $default = '')
27
    {
28
        return $this->getInterpolator()->interpolate($this, $message, $default);
29
    }
30
31
    /**
32
     * @inheritdoc
33
     */
34
    public function mustInterpolate($message)
35
    {
36
        return $this->getInterpolator()->mustInterpolate($this, $message);
37
    }
38
}
39