Passed
Push — master ( ac1451...1d2831 )
by Alan
02:29 queued 11s
created

Configurable::setConfigFactory()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 5
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
namespace FigTree\Config\Concerns;
4
5
use FigTree\Config\Contracts\{
6
	ConfigRepositoryInterface,
7
	ConfigInterface,
8
	ConfigurableInterface,
9
};
10
11
trait Configurable
12
{
13
	/**
14
	 * ConfigRepository instance.
15
	 *
16
	 * @var \FigTree\Config\Contracts\ConfigRepositoryInterface
17
	 */
18
	protected ConfigRepositoryInterface $configRepo;
19
20
	/**
21
	 * Set the Config instance.
22
	 *
23
	 * @param \FigTree\Config\Contracts\ConfigRepositoryInterface $configRepo
24
	 *
25
	 * @return $this
26
	 */
27
	public function setConfigRepository(ConfigRepositoryInterface $configRepo)
28
	{
29
		$this->configRepo = $configRepo;
30
31
		return $this;
32
	}
33
34
	/**
35
	 * Shorthand to either get the associated Config instance or the given
36
	 * top-level key from the Config file.
37
	 *
38
	 * @param string $fileName
39
	 *
40
	 * @return \FigTree\Config\Contracts\ConfigInterface
41
	 */
42
	protected function config(string $fileName): ConfigInterface
43
	{
44
		return $this->configRepo->get($fileName);
45
	}
46
}
47