-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathOptionsUtil.php
More file actions
35 lines (31 loc) · 942 Bytes
/
OptionsUtil.php
File metadata and controls
35 lines (31 loc) · 942 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
namespace TryLib\Util;
class OptionsUtil {
/**
* parse a param string in the form of k=v
* and return an array of 2 elements (key,value)
* if value does not exists, use ""
*/
public static function parseParam($param) {
$p = explode('=', $param, 2);
if (count($p) === 1) {
$p[] = "";
}
return $p;
}
/**
* Parse a string or array of extra_param options formatted as key=value
* and return an array of key->value
*/
public static function parseExtraParameters($extra_param_option) {
$params = [];
if (is_string($extra_param_option)) {
$params[] = self::parseParam($extra_param_option);
} elseif (is_array($extra_param_option)) {
foreach ($extra_param_option as $param) {
$params[] = self::parseParam($param);
}
}
return $params;
}
}