1 | <?php |
||
24 | abstract class WebServer implements WebServerInterface |
||
25 | { |
||
26 | /** |
||
27 | * the name of a webserver. |
||
28 | * |
||
29 | * @var string the name of a webserver |
||
30 | */ |
||
31 | private $name; |
||
32 | |||
33 | /** |
||
34 | * the version of a webserver. |
||
35 | * |
||
36 | * @var string the version of a webserver |
||
37 | */ |
||
38 | private $version; |
||
39 | |||
40 | /** |
||
41 | * binaries that can be used to control the webserver. |
||
42 | * |
||
43 | * @var array |
||
44 | */ |
||
45 | private $binaries = []; |
||
46 | |||
47 | /** |
||
48 | * the parameter string to use to detect version and config file. |
||
49 | * |
||
50 | * @var string |
||
51 | */ |
||
52 | private $detectionParameter = ''; |
||
53 | |||
54 | /** |
||
55 | * a web config parser. |
||
56 | * |
||
57 | * @var ParserInterface |
||
58 | */ |
||
59 | protected $parser; |
||
60 | |||
61 | /** |
||
62 | * Constructor. |
||
63 | * |
||
64 | * @param string $name the name of a webserver |
||
65 | * @param string $version the version of a webserver |
||
66 | */ |
||
67 | 33 | public function __construct($name, $version = '') |
|
72 | |||
73 | /** |
||
74 | * Gets the name of a webserver. |
||
75 | * |
||
76 | * @return string the name of the webserver |
||
77 | */ |
||
78 | 8 | public function getName() |
|
82 | |||
83 | /** |
||
84 | * Gets the version of a webserver. |
||
85 | * |
||
86 | * @return string the version of the webserver |
||
87 | */ |
||
88 | 5 | public function getVersion() |
|
92 | |||
93 | /** |
||
94 | * Gets the list of binaries that can be run to analyze. |
||
95 | * |
||
96 | * @return array the list of binaries that can be run |
||
97 | */ |
||
98 | 7 | public function getBinaries() |
|
102 | |||
103 | 21 | public function setBinaries(array $binaries) |
|
109 | |||
110 | 21 | public function setDetectionParameter($parameter = '') |
|
116 | |||
117 | 3 | public function getSettings($fullPathBinary) |
|
124 | |||
125 | abstract public function extractVersion($settings = ''); |
||
126 | |||
127 | abstract public function extractRootConfigurationFile($settings = ''); |
||
128 | |||
129 | /** |
||
130 | * Finds and return a specific information in a string. |
||
131 | * |
||
132 | * the regexp must contain delimiters. |
||
133 | * |
||
134 | * @param string $regexp a regular expression to find |
||
135 | * @param string $settings a string where to find |
||
136 | * |
||
137 | * @return string the found value or an empty string |
||
138 | */ |
||
139 | 11 | protected function match($regexp, $settings) |
|
149 | |||
150 | /** |
||
151 | * Loads and cleans a config file. |
||
152 | * |
||
153 | * @param string $file a Configuration file |
||
154 | * |
||
155 | * @return array an array of the cleaned directives of a the config per entry |
||
156 | */ |
||
157 | abstract public function getActiveConfig($file = ''); |
||
158 | } |
||
159 |