ConfigInterpolatorTrait::getInterpolator()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 0
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