|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* MageSpec |
|
4
|
|
|
* |
|
5
|
|
|
* NOTICE OF LICENSE |
|
6
|
|
|
* |
|
7
|
|
|
* This source file is subject to the MIT License, that is bundled with this |
|
8
|
|
|
* package in the file LICENSE. |
|
9
|
|
|
* It is also available through the world-wide-web at this URL: |
|
10
|
|
|
* |
|
11
|
|
|
* http://opensource.org/licenses/MIT |
|
12
|
|
|
* |
|
13
|
|
|
* If you did not receive a copy of the license and are unable to obtain it |
|
14
|
|
|
* through the world-wide-web, please send an email |
|
15
|
|
|
* to <[email protected]> so we can send you a copy immediately. |
|
16
|
|
|
* |
|
17
|
|
|
* @category MageTest |
|
18
|
|
|
* @package PhpSpec_MagentoExtension |
|
19
|
|
|
* |
|
20
|
|
|
* @copyright Copyright (c) 2012-2013 MageTest team and contributors. |
|
21
|
|
|
*/ |
|
22
|
|
|
namespace MageTest\PhpSpec\MagentoExtension\Configuration; |
|
23
|
|
|
|
|
24
|
|
|
class MageLocator |
|
25
|
|
|
{ |
|
26
|
|
|
const DEFAULT_SRC_PATH = 'src'; |
|
27
|
|
|
|
|
28
|
|
|
private $configuration; |
|
29
|
|
|
|
|
30
|
|
|
private function __construct(array $params) |
|
31
|
|
|
{ |
|
32
|
|
|
$this->configuration = isset($params['mage_locator']) ? $params['mage_locator'] : []; |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
public static function fromParams(array $params = []) |
|
36
|
|
|
{ |
|
37
|
|
|
return new MageLocator($params); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
public function getNamespace() |
|
41
|
|
|
{ |
|
42
|
|
|
return array_key_exists('namespace', $this->configuration) ? $this->configuration['namespace'] : ''; |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
public function getSpecPrefix() |
|
46
|
|
|
{ |
|
47
|
|
|
return array_key_exists('spec_prefix', $this->configuration) ? $this->configuration['spec_prefix'] : ''; |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
public function getSrcPath() |
|
51
|
|
|
{ |
|
52
|
|
|
return array_key_exists('src_path', $this->configuration) ? |
|
53
|
|
|
rtrim($this->configuration['src_path'], '/') . DIRECTORY_SEPARATOR : |
|
54
|
|
|
self::DEFAULT_SRC_PATH; |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
public function getSpecPath() |
|
58
|
|
|
{ |
|
59
|
|
|
return array_key_exists('spec_path', $this->configuration) ? |
|
60
|
|
|
rtrim($this->configuration['spec_path'], '/') . DIRECTORY_SEPARATOR : |
|
61
|
|
|
'.'; |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
public function getCodePool() |
|
65
|
|
|
{ |
|
66
|
|
|
return array_key_exists('code_pool', $this->configuration) ? $this->configuration['code_pool'] : 'local'; |
|
67
|
|
|
} |
|
68
|
|
|
} |
|
69
|
|
|
|