forked from marcocesarato/PHP-Antimalware-Scanner
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFlag.php
More file actions
76 lines (70 loc) · 1.57 KB
/
Copy pathFlag.php
File metadata and controls
76 lines (70 loc) · 1.57 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?php
/**
* PHP Antimalware Scanner.
*
* @author Marco Cesarato <cesarato.developer@gmail.com>
* @license http://opensource.org/licenses/gpl-3.0.html GNU Public License
*
* @see https://github.com/marcocesarato/PHP-Antimalware-Scanner
*/
namespace AMWScan\Console;
/**
* Class Flag.
*/
class Flag
{
/**
* @var string
*/
public $name;
/**
* @var null
*/
public $callback;
/**
* @var array
*/
public $aliases = [];
/**
* @var bool
*/
public $hasValue = false;
/**
* @var string
*/
public $valueName;
public $defaultValue;
public $var;
public $help;
/**
* Flag constructor.
*
* @param array $options
* @param null $callback
*/
public function __construct($name, $options = [], $callback = null)
{
$this->name = $name;
$this->callback = $callback;
$this->aliases = array_merge(["--$name"], (array)@$options['alias']);
$this->defaultValue = @$options['default'];
$this->hasValue = (bool)@$options['has_value'];
$this->valueName = @$options['value_name'];
$this->help = @$options['help'];
if (array_key_exists('var', $options)) {
$this->var = &$options['var'];
}
}
/**
* @return string
*/
public function __toString()
{
$s = implode('|', $this->aliases);
if ($this->hasValue) {
$name = empty($this->valueName) ? $this->name : $this->valueName;
$s = "$s <{$name}>";
}
return "[$s]";
}
}