PluginProbe ʕ •ᴥ•ʔ
Matomo Analytics – Powerful, Privacy-First Insights for WordPress / 5.2.0
Matomo Analytics – Powerful, Privacy-First Insights for WordPress v5.2.0
5.11.1 5.11.0 5.10.2 5.10.1 trunk 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.3.0 1.3.1 1.3.2 4.0.0 4.0.1 4.0.2 4.0.3 4.0.4 4.1.0 4.1.1 4.1.2 4.1.3 4.10.0 4.11.0 4.12.0 4.13.0 4.13.2 4.13.3 4.13.4 4.13.5 4.14.0 4.14.1 4.14.2 4.15.0 4.15.1 4.15.2 4.15.3 4.2.0 4.3.0 4.3.1 4.4.1 4.4.2 4.5.0 4.6.0 5.0.1 5.0.2 5.0.3 5.0.4 5.0.5 5.0.6 5.0.7 5.0.8 5.1.0 5.1.1 5.1.2 5.1.3 5.1.4 5.1.5 5.1.6 5.1.7 5.10.0 5.2.0 5.2.1 5.2.2 5.3.0 5.3.1 5.3.2 5.3.3 5.6.0 5.6.1 5.7.0 5.7.1 5.8.0 5.8.1 5.8.2
matomo / app / vendor / composer / semver / src / Constraint / MultiConstraint.php
matomo / app / vendor / composer / semver / src / Constraint Last commit date
AbstractConstraint.php 3 years ago Constraint.php 3 years ago ConstraintInterface.php 6 years ago EmptyConstraint.php 3 years ago MultiConstraint.php 3 years ago
MultiConstraint.php
121 lines
1 <?php
2
3 /*
4 * This file is part of composer/semver.
5 *
6 * (c) Composer <https://github.com/composer>
7 *
8 * For the full copyright and license information, please view
9 * the LICENSE file that was distributed with this source code.
10 */
11
12 namespace Composer\Semver\Constraint;
13
14 /**
15 * Defines a conjunctive or disjunctive set of constraints.
16 */
17 class MultiConstraint implements ConstraintInterface
18 {
19 /** @var ConstraintInterface[] */
20 protected $constraints;
21
22 /** @var string|null */
23 protected $prettyString;
24
25 /** @var bool */
26 protected $conjunctive;
27
28 /**
29 * @param ConstraintInterface[] $constraints A set of constraints
30 * @param bool $conjunctive Whether the constraints should be treated as conjunctive or disjunctive
31 */
32 public function __construct(array $constraints, $conjunctive = true)
33 {
34 $this->constraints = $constraints;
35 $this->conjunctive = $conjunctive;
36 }
37
38 /**
39 * @return ConstraintInterface[]
40 */
41 public function getConstraints()
42 {
43 return $this->constraints;
44 }
45
46 /**
47 * @return bool
48 */
49 public function isConjunctive()
50 {
51 return $this->conjunctive;
52 }
53
54 /**
55 * @return bool
56 */
57 public function isDisjunctive()
58 {
59 return !$this->conjunctive;
60 }
61
62 /**
63 * @param ConstraintInterface $provider
64 *
65 * @return bool
66 */
67 public function matches(ConstraintInterface $provider)
68 {
69 if (false === $this->conjunctive) {
70 foreach ($this->constraints as $constraint) {
71 if ($constraint->matches($provider)) {
72 return true;
73 }
74 }
75
76 return false;
77 }
78
79 foreach ($this->constraints as $constraint) {
80 if (!$constraint->matches($provider)) {
81 return false;
82 }
83 }
84
85 return true;
86 }
87
88 /**
89 * @param string|null $prettyString
90 */
91 public function setPrettyString($prettyString)
92 {
93 $this->prettyString = $prettyString;
94 }
95
96 /**
97 * @return string
98 */
99 public function getPrettyString()
100 {
101 if ($this->prettyString) {
102 return $this->prettyString;
103 }
104
105 return (string) $this;
106 }
107
108 /**
109 * @return string
110 */
111 public function __toString()
112 {
113 $constraints = array();
114 foreach ($this->constraints as $constraint) {
115 $constraints[] = (string) $constraint;
116 }
117
118 return '[' . implode($this->conjunctive ? ' ' : ' || ', $constraints) . ']';
119 }
120 }
121