1
|
|
|
<?php |
2
|
|
|
namespace Ciandt\Behat\PlaceholdersExtension\Config; |
3
|
|
|
|
4
|
|
|
use Symfony\Component\Yaml\Yaml; |
5
|
|
|
|
6
|
|
|
/** |
7
|
|
|
* Description of ConfigsRepository |
8
|
|
|
* |
9
|
|
|
* @author bwowk |
10
|
|
|
*/ |
11
|
|
|
class PlaceholdersRepository |
12
|
|
|
{ |
13
|
|
|
|
14
|
|
|
private $configs; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* @var string |
18
|
|
|
*/ |
19
|
|
|
private $environment; |
20
|
|
|
|
21
|
|
|
public function __construct($configs_mapping) |
22
|
|
|
{ |
23
|
|
|
$this->configs = array(); |
24
|
|
|
$this->loadConfigFiles($configs_mapping); |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* |
29
|
|
|
* @return string[] |
30
|
|
|
* @todo read configs and also bring alternative @config:section tags |
31
|
|
|
*/ |
32
|
|
|
public function getTags() |
33
|
|
|
{ |
34
|
|
|
return array_keys($this->configs); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* |
39
|
|
|
* @param type $config_files |
|
|
|
|
40
|
|
|
* @todo user %paths.base% value |
41
|
|
|
*/ |
42
|
|
|
private function loadConfigFiles($configs_mapping) |
43
|
|
|
{ |
44
|
|
|
$placeholder_maps = array(); |
45
|
|
|
foreach ($configs_mapping as $tag => $file_path) { |
46
|
|
|
$placeholder_maps[$tag]['config'] = Yaml::parse(file_get_contents($file_path)); |
47
|
|
|
$placeholder_maps[$tag]['path'] = $file_path; |
48
|
|
|
} |
49
|
|
|
$this->configs = $placeholder_maps; |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
public function getConfigSection($tag, $section) |
53
|
|
|
{ |
54
|
|
|
if ($this->hasTag($tag)) { |
55
|
|
|
return $this->configs[$tag]['config'][$section]; |
56
|
|
|
} |
57
|
|
|
return null; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
public function getFilePath($tag) |
61
|
|
|
{ |
62
|
|
|
if ($this->hasTag($tag)) { |
63
|
|
|
return $this->configs[$tag]['path']; |
64
|
|
|
} |
65
|
|
|
return null; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
public function hasTag($tag) |
69
|
|
|
{ |
70
|
|
|
if (key_exists($tag, $this->configs)) { |
71
|
|
|
return true; |
72
|
|
|
} else { |
73
|
|
|
return false; |
74
|
|
|
} |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
public function getEnvironment() |
78
|
|
|
{ |
79
|
|
|
return $this->environment; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
public function setEnvironment($environment) |
83
|
|
|
{ |
84
|
|
|
$this->environment = $environment; |
85
|
|
|
} |
86
|
|
|
} |
87
|
|
|
|
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.