PluginProbe
WindPress – Tailwind CSS integration for WordPress / 3.2.85
WindPress – Tailwind CSS integration for WordPress v3.2.85
3.2.90 3.2.89 3.2.88 3.2.87 3.2.86 3.2.85 3.2.84 3.2.83 3.2.82 3.2.81 trunk 3.0.0 3.0.1 3.0.10 3.0.11 3.0.12 3.0.13 3.0.14 3.0.15 3.0.16 3.0.17 3.0.2 3.0.3 3.0.4 3.0.5 All 144 releases
windpress / vendor / symfony / finder / Comparator / Comparator.php

Comparator.php in WindPress – Tailwind CSS integration for WordPress 3.2.85, at vendor/symfony/finder/Comparator/Comparator.php

103 lines 3.0 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 <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 WindPressDeps\Symfony\Component\Finder\Comparator;
12
13 /**
14 * @author Fabien Potencier <fabien@symfony.com>
15 */
16 class Comparator
17 {
18 private $target;
19 private $operator = '==';
20 public function __construct(?string $target = null, string $operator = '==')
21 {
22 if (null === $target) {
23 trigger_deprecation('symfony/finder', '5.4', 'Constructing a "%s" without setting "$target" is deprecated.', __CLASS__);
24 }
25 $this->target = $target;
26 $this->doSetOperator($operator);
27 }
28 /**
29 * Gets the target value.
30 *
31 * @return string
32 */
33 public function getTarget()
34 {
35 if (null === $this->target) {
36 trigger_deprecation('symfony/finder', '5.4', 'Calling "%s" without initializing the target is deprecated.', __METHOD__);
37 }
38 return $this->target;
39 }
40 /**
41 * @deprecated set the target via the constructor instead
42 */
43 public function setTarget(string $target)
44 {
45 trigger_deprecation('symfony/finder', '5.4', '"%s" is deprecated. Set the target via the constructor instead.', __METHOD__);
46 $this->target = $target;
47 }
48 /**
49 * Gets the comparison operator.
50 *
51 * @return string
52 */
53 public function getOperator()
54 {
55 return $this->operator;
56 }
57 /**
58 * Sets the comparison operator.
59 *
60 * @throws \InvalidArgumentException
61 *
62 * @deprecated set the operator via the constructor instead
63 */
64 public function setOperator(string $operator)
65 {
66 trigger_deprecation('symfony/finder', '5.4', '"%s" is deprecated. Set the operator via the constructor instead.', __METHOD__);
67 $this->doSetOperator('' === $operator ? '==' : $operator);
68 }
69 /**
70 * Tests against the target.
71 *
72 * @param mixed $test A test value
73 *
74 * @return bool
75 */
76 public function test($test)
77 {
78 if (null === $this->target) {
79 trigger_deprecation('symfony/finder', '5.4', 'Calling "%s" without initializing the target is deprecated.', __METHOD__);
80 }
81 switch ($this->operator) {
82 case '>':
83 return $test > $this->target;
84 case '>=':
85 return $test >= $this->target;
86 case '<':
87 return $test < $this->target;
88 case '<=':
89 return $test <= $this->target;
90 case '!=':
91 return $test != $this->target;
92 }
93 return $test == $this->target;
94 }
95 private function doSetOperator(string $operator): void
96 {
97 if (!\in_array($operator, ['>', '<', '>=', '<=', '==', '!='])) {
98 throw new \InvalidArgumentException(sprintf('Invalid operator "%s".', $operator));
99 }
100 $this->operator = $operator;
101 }
102 }
103