Completed
Push — master ( 3cd165...ad6ad2 )
by Aimeos
02:44
created

Config::get()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 17
Code Lines 9

Duplication

Lines 3
Ratio 17.65 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 3
loc 17
rs 9.2
cc 4
eloc 9
nc 4
nop 1
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2016
6
 * @package Slim
7
 * @subpackage Base
8
 */
9
10
namespace Aimeos\Slim\Base;
11
12
use Interop\Container\ContainerInterface;
13
14
15
/**
16
 * Service providing the config objects
17
 *
18
 * @package Slim
19
 * @subpackage Base
20
 */
21
class Config
22
{
23
	private $container;
24
	private $settings;
25
26
27
	/**
28
	 * Initializes the object
29
	 *
30
	 * @param ContainerInterface $container Dependency container
31
	 */
32
	public function __construct( ContainerInterface $container, $settings )
33
	{
34
		$this->container = $container;
35
		$this->settings = $settings;
36
	}
37
38
39
	/**
40
	 * Returns the config object
41
	 *
42
	 * @param string $type Configuration type ("frontend" or "backend")
43
	 * @return \Aimeos\MW\Config\Iface Config object
44
	 */
45
	public function get( $type = 'frontend' )
46
	{
47
		$paths = $this->container->get( 'aimeos' )->getConfigPaths();
48
		$config = new \Aimeos\MW\Config\PHPArray( array(), $paths );
49
50 View Code Duplication
		if( function_exists( 'apc_store' ) === true && $config->get( 'apc_enabled', false ) == true ) {
1 ignored issue
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
51
			$config = new \Aimeos\MW\Config\Decorator\APC( $config, $config->get( 'apc_prefix', 'slim:' ) );
52
		}
53
54
		$config = new \Aimeos\MW\Config\Decorator\Memory( $config, $this->settings );
55
56
		if( isset( $this->settings[$type] ) ) {
57
			$config = new \Aimeos\MW\Config\Decorator\Memory( $config, $this->settings[$type] );
58
		}
59
60
		return $config;
61
	}
62
}
63