PluginProbe ʕ •ᴥ•ʔ
Independent Analytics – WordPress Analytics Plugin / 2.2.0
Independent Analytics – WordPress Analytics Plugin v2.2.0
2.15.0 2.14.10 trunk 1.1 1.10 1.10.1 1.11 1.12 1.13 1.14 1.15 1.16 1.17 1.17.1 1.17.2 1.17.3 1.17.4 1.18 1.18.1 1.19.0 1.19.1 1.2 1.20.0 1.21.0 1.22.0 1.22.1 1.23.0 1.23.1 1.24.0 1.24.1 1.25.0 1.25.1 1.26.0 1.27.0 1.28.0 1.28.1 1.28.2 1.28.3 1.29.0 1.3 1.30.0 1.30.1 1.4 1.5 1.6 1.7 1.8 1.9 2.0.0 2.0.1 2.1.4 2.1.5 2.1.6 2.10.0 2.10.1 2.10.2 2.10.3 2.10.4 2.11.0 2.11.1 2.11.10 2.11.2 2.11.3 2.11.4 2.11.5 2.11.6 2.11.7 2.11.8 2.11.9 2.12.0 2.12.1 2.12.2 2.13.1 2.13.2 2.13.5 2.13.6 2.14.0 2.14.1 2.14.2 2.14.4 2.14.6 2.14.7 2.14.8 2.14.9 2.2.0 2.2.1 2.3.1 2.3.2 2.4.2 2.4.3 2.5.0 2.5.1 2.6.0 2.6.1 2.6.2 2.6.3 2.6.4 2.7.0 2.7.1 2.7.2 2.7.3 2.8.2 2.8.3 2.8.4 2.8.5 2.8.6 2.8.7 2.8.8 2.8.9 2.9.2 2.9.3 2.9.4 2.9.5 2.9.6 2.9.7
independent-analytics / vendor / symfony / console / Input / Input.php
independent-analytics / vendor / symfony / console / Input Last commit date
ArgvInput.php 2 years ago ArrayInput.php 2 years ago Input.php 2 years ago InputArgument.php 2 years ago InputAwareInterface.php 2 years ago InputDefinition.php 2 years ago InputInterface.php 2 years ago InputOption.php 2 years ago StreamableInputInterface.php 2 years ago StringInput.php 2 years ago
Input.php
186 lines
1 <?php
2
3 /*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11 namespace IAWP_SCOPED\Symfony\Component\Console\Input;
12
13 use IAWP_SCOPED\Symfony\Component\Console\Exception\InvalidArgumentException;
14 use IAWP_SCOPED\Symfony\Component\Console\Exception\RuntimeException;
15 /**
16 * Input is the base class for all concrete Input classes.
17 *
18 * Three concrete classes are provided by default:
19 *
20 * * `ArgvInput`: The input comes from the CLI arguments (argv)
21 * * `StringInput`: The input is provided as a string
22 * * `ArrayInput`: The input is provided as an array
23 *
24 * @author Fabien Potencier <fabien@symfony.com>
25 * @internal
26 */
27 abstract class Input implements InputInterface, StreamableInputInterface
28 {
29 protected $definition;
30 protected $stream;
31 protected $options = [];
32 protected $arguments = [];
33 protected $interactive = \true;
34 public function __construct(InputDefinition $definition = null)
35 {
36 if (null === $definition) {
37 $this->definition = new InputDefinition();
38 } else {
39 $this->bind($definition);
40 $this->validate();
41 }
42 }
43 /**
44 * {@inheritdoc}
45 */
46 public function bind(InputDefinition $definition)
47 {
48 $this->arguments = [];
49 $this->options = [];
50 $this->definition = $definition;
51 $this->parse();
52 }
53 /**
54 * Processes command line arguments.
55 */
56 protected abstract function parse();
57 /**
58 * {@inheritdoc}
59 */
60 public function validate()
61 {
62 $definition = $this->definition;
63 $givenArguments = $this->arguments;
64 $missingArguments = \array_filter(\array_keys($definition->getArguments()), function ($argument) use($definition, $givenArguments) {
65 return !\array_key_exists($argument, $givenArguments) && $definition->getArgument($argument)->isRequired();
66 });
67 if (\count($missingArguments) > 0) {
68 throw new RuntimeException(\sprintf('Not enough arguments (missing: "%s").', \implode(', ', $missingArguments)));
69 }
70 }
71 /**
72 * {@inheritdoc}
73 */
74 public function isInteractive()
75 {
76 return $this->interactive;
77 }
78 /**
79 * {@inheritdoc}
80 */
81 public function setInteractive(bool $interactive)
82 {
83 $this->interactive = $interactive;
84 }
85 /**
86 * {@inheritdoc}
87 */
88 public function getArguments()
89 {
90 return \array_merge($this->definition->getArgumentDefaults(), $this->arguments);
91 }
92 /**
93 * {@inheritdoc}
94 */
95 public function getArgument(string $name)
96 {
97 if (!$this->definition->hasArgument($name)) {
98 throw new InvalidArgumentException(\sprintf('The "%s" argument does not exist.', $name));
99 }
100 return $this->arguments[$name] ?? $this->definition->getArgument($name)->getDefault();
101 }
102 /**
103 * {@inheritdoc}
104 */
105 public function setArgument(string $name, $value)
106 {
107 if (!$this->definition->hasArgument($name)) {
108 throw new InvalidArgumentException(\sprintf('The "%s" argument does not exist.', $name));
109 }
110 $this->arguments[$name] = $value;
111 }
112 /**
113 * {@inheritdoc}
114 */
115 public function hasArgument(string $name)
116 {
117 return $this->definition->hasArgument($name);
118 }
119 /**
120 * {@inheritdoc}
121 */
122 public function getOptions()
123 {
124 return \array_merge($this->definition->getOptionDefaults(), $this->options);
125 }
126 /**
127 * {@inheritdoc}
128 */
129 public function getOption(string $name)
130 {
131 if ($this->definition->hasNegation($name)) {
132 if (null === ($value = $this->getOption($this->definition->negationToName($name)))) {
133 return $value;
134 }
135 return !$value;
136 }
137 if (!$this->definition->hasOption($name)) {
138 throw new InvalidArgumentException(\sprintf('The "%s" option does not exist.', $name));
139 }
140 return \array_key_exists($name, $this->options) ? $this->options[$name] : $this->definition->getOption($name)->getDefault();
141 }
142 /**
143 * {@inheritdoc}
144 */
145 public function setOption(string $name, $value)
146 {
147 if ($this->definition->hasNegation($name)) {
148 $this->options[$this->definition->negationToName($name)] = !$value;
149 return;
150 } elseif (!$this->definition->hasOption($name)) {
151 throw new InvalidArgumentException(\sprintf('The "%s" option does not exist.', $name));
152 }
153 $this->options[$name] = $value;
154 }
155 /**
156 * {@inheritdoc}
157 */
158 public function hasOption(string $name)
159 {
160 return $this->definition->hasOption($name) || $this->definition->hasNegation($name);
161 }
162 /**
163 * Escapes a token through escapeshellarg if it contains unsafe chars.
164 *
165 * @return string
166 */
167 public function escapeToken(string $token)
168 {
169 return \preg_match('{^[\\w-]+$}', $token) ? $token : \escapeshellarg($token);
170 }
171 /**
172 * {@inheritdoc}
173 */
174 public function setStream($stream)
175 {
176 $this->stream = $stream;
177 }
178 /**
179 * {@inheritdoc}
180 */
181 public function getStream()
182 {
183 return $this->stream;
184 }
185 }
186