PluginProbe
Defender Security – Malware Scanner, Login Security & Firewall / 5.3.1
Defender Security – Malware Scanner, Login Security & Firewall v5.3.1
6.3.0 6.2.3 6.2.4 6.2.0 6.2.1 6.2.2 6.1.0 5.3.1 5.4.0 5.4.1 5.5.0 5.5.1 5.6.0 5.6.1 5.6.2 5.7.0 5.7.1 5.7.2 5.8.0 5.8.1 5.9.0 6.0.0 6.0.1 3.0.1 3.1.0 All 141 releases
defender-security / vendor / symfony / process / ProcessUtils.php

ProcessUtils.php in Defender Security – Malware Scanner, Login Security & Firewall 5.3.1, at vendor/symfony/process/ProcessUtils.php

70 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <[email protected]>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12 namespace Symfony\Component\Process;
13
14 use Symfony\Component\Process\Exception\InvalidArgumentException;
15
16 /**
17 * ProcessUtils is a bunch of utility methods.
18 *
19 * This class contains static methods only and is not meant to be instantiated.
20 *
21 * @author Martin Hasoň <[email protected]>
22 */
23 class ProcessUtils
24 {
25 /**
26 * This class should not be instantiated.
27 */
28 private function __construct()
29 {
30 }
31
32 /**
33 * Validates and normalizes a Process input.
34 *
35 * @param string $caller The name of method call that validates the input
36 * @param mixed $input The input to validate
37 *
38 * @return mixed
39 *
40 * @throws InvalidArgumentException In case the input is not valid
41 */
42 public static function validateInput(string $caller, $input)
43 {
44 if (null !== $input) {
45 if (\is_resource($input)) {
46 return $input;
47 }
48 if (\is_string($input)) {
49 return $input;
50 }
51 if (\is_scalar($input)) {
52 return (string) $input;
53 }
54 if ($input instanceof Process) {
55 return $input->getIterator($input::ITER_SKIP_ERR);
56 }
57 if ($input instanceof \Iterator) {
58 return $input;
59 }
60 if ($input instanceof \Traversable) {
61 return new \IteratorIterator($input);
62 }
63
64 throw new InvalidArgumentException(sprintf('"%s" only accepts strings, Traversable objects or stream resources.', $caller));
65 }
66
67 return $input;
68 }
69 }
70