Completed
Push — master ( 9c14a5...11d3c4 )
by Aimeos
02:55
created

Laravel::get()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 15
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 15
rs 9.4286
cc 3
eloc 7
nc 3
nop 1
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2015
6
 * @package MW
7
 * @subpackage Filesystem
8
 */
9
10
11
namespace Aimeos\MW\Filesystem\Manager;
12
13
14
/**
15
 * Laravel file system manager
16
 *
17
 * @package MW
18
 * @subpackage Filesystem
19
 */
20
class Laravel extends Standard implements Iface
21
{
22
	private $objects = array();
23
	private $fsm;
24
25
26
	/**
27
	 * Initializes the object
28
	 *
29
	 * @param \Illuminate\Filesystem\FilesystemManager $fsm Laravel file system manager object
30
	 * @param \Aimeos\MW\Config\Iface $config Configuration object
31
	 */
32
	public function __construct( \Illuminate\Filesystem\FilesystemManager $fsm, \Aimeos\MW\Config\Iface $config )
33
	{
34
		parent::__construct( $config );
35
36
		$this->fsm = $fsm;
37
	}
38
39
40
	/**
41
	 * Returns the file system for the given name
42
	 *
43
	 * @param string $name Key for the file system
44
	 * @return \Aimeos\MW\Filesystem\Iface File system object
45
	 * @throws \Aimeos\MW\Filesystem\Exception If an no configuration for that name is found
46
	 */
47
	public function get( $name )
48
	{
49
		$key = $this->getConfig( $name );
50
51
		if( is_string( $key ) )
52
		{
53
			if( !isset( $this->objects[$key] ) ) {
54
				$this->objects[$key] = new \Aimeos\MW\Filesystem\Laravel( $this->fsm->disk( $key ) );
55
			}
56
57
			return $this->objects[$key];
58
		}
59
60
		return parent::get( $name );
61
	}
62
}
63