Verzeichnisstruktur phpBB-3.3.15
- Veröffentlicht
- 28.08.2024
So funktioniert es
|
Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück |
Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
Comparisons.php
001 <?php
002
003 /**
004 * @package s9e\TextFormatter
005 * @copyright Copyright (c) 2010-2022 The s9e authors
006 * @license http://www.opensource.org/licenses/mit-license.php The MIT License
007 */
008 namespace s9e\TextFormatter\Configurator\RendererGenerators\PHP\XPathConvertor\Convertors;
009
010 class Comparisons extends AbstractConvertor
011 {
012 /**
013 * {@inheritdoc}
014 */
015 public function getMatchers(): array
016 {
017 $nonzero = '(0*[1-9]\\d*)';
018 $number = '(\\d+)';
019 $scalar = '((?&Math)|(?&Number)|(?&String))';
020
021 return [
022 'Boolean:Eq' => $scalar . ' (!?=) ' . $scalar,
023 'Boolean:Gt' => $scalar . ' > ' . $number,
024 'Boolean:Gte' => $scalar . ' >= ' . $nonzero,
025 'Boolean:Lt' => $number . ' < ' . $scalar,
026 'Boolean:Lte' => $nonzero . ' <= ' . $scalar
027 ];
028 }
029
030 /**
031 * Convert an equality test
032 *
033 * @param string $expr1
034 * @param string $operator
035 * @param string $expr2
036 * @return string
037 */
038 public function parseEq($expr1, $operator, $expr2)
039 {
040 $parsedExpr1 = $this->parser->parse($expr1);
041 $parsedExpr2 = $this->parser->parse($expr2);
042
043 $operator = $operator[0] . '=';
044 if (in_array('String', $parsedExpr1['groups'], true) && in_array('String', $parsedExpr2['groups'], true))
045 {
046 $operator .= '=';
047 }
048
049 return $parsedExpr1['value'] . $operator . $parsedExpr2['value'];
050 }
051
052 /**
053 * Convert a "greater than" comparison
054 *
055 * @param string $expr1
056 * @param string $expr2
057 * @return string
058 */
059 public function parseGt($expr1, $expr2)
060 {
061 return $this->convertComparison($expr1, '>', $expr2);
062 }
063
064 /**
065 * Convert a "greater than or equal to" comparison
066 *
067 * @param string $expr1
068 * @param string $expr2
069 * @return string
070 */
071 public function parseGte($expr1, $expr2)
072 {
073 return $this->convertComparison($expr1, '>=', $expr2);
074 }
075
076 /**
077 * Convert a "less than" comparison
078 *
079 * @param string $expr1
080 * @param string $expr2
081 * @return string
082 */
083 public function parseLt($expr1, $expr2)
084 {
085 return $this->convertComparison($expr1, '<', $expr2);
086 }
087
088 /**
089 * Convert a "less than or equal to" comparison
090 *
091 * @param string $expr1
092 * @param string $expr2
093 * @return string
094 */
095 public function parseLte($expr1, $expr2)
096 {
097 return $this->convertComparison($expr1, '<=', $expr2);
098 }
099
100 /**
101 * Convert a comparison
102 *
103 * @param string $expr1
104 * @param string $operator
105 * @param string $expr2
106 * @return string
107 */
108 protected function convertComparison($expr1, $operator, $expr2)
109 {
110 return $this->recurse($expr1) . $operator . $this->recurse($expr2);
111 }
112 }