|
| 1 | +<?php |
| 2 | + |
| 3 | +/* |
| 4 | + * Cypher DSL |
| 5 | + * Copyright (C) 2021 Wikibase Solutions |
| 6 | + * |
| 7 | + * This program is free software; you can redistribute it and/or |
| 8 | + * modify it under the terms of the GNU General Public License |
| 9 | + * as published by the Free Software Foundation; either version 2 |
| 10 | + * of the License, or (at your option) any later version. |
| 11 | + * |
| 12 | + * This program is distributed in the hope that it will be useful, |
| 13 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | + * GNU General Public License for more details. |
| 16 | + * |
| 17 | + * You should have received a copy of the GNU General Public License |
| 18 | + * along with this program; if not, write to the Free Software |
| 19 | + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 20 | + */ |
| 21 | + |
| 22 | +namespace WikibaseSolutions\CypherDSL\Traits; |
| 23 | + |
| 24 | +use WikibaseSolutions\CypherDSL\GreaterThan; |
| 25 | +use WikibaseSolutions\CypherDSL\GreaterThanOrEqual; |
| 26 | +use WikibaseSolutions\CypherDSL\LessThan; |
| 27 | +use WikibaseSolutions\CypherDSL\LessThanOrEqual; |
| 28 | +use WikibaseSolutions\CypherDSL\Types\PropertyTypes\ComparableType; |
| 29 | + |
| 30 | +/** |
| 31 | + * This trait should be used by any expression that returns a numeral. |
| 32 | + */ |
| 33 | +trait ComparableTypeTrait |
| 34 | +{ |
| 35 | + use PropertyTypeTrait; |
| 36 | + |
| 37 | + /** |
| 38 | + * Perform a greater than comparison against the given expression. |
| 39 | + * |
| 40 | + * @param ComparableType $right |
| 41 | + * @param bool $insertParentheses |
| 42 | + * @return GreaterThan |
| 43 | + */ |
| 44 | + public function gt(ComparableType $right, bool $insertParentheses = true): GreaterThan |
| 45 | + { |
| 46 | + return new GreaterThan($this, $right, $insertParentheses); |
| 47 | + } |
| 48 | + |
| 49 | + /** |
| 50 | + * Perform a greater than or equal comparison against the given expression. |
| 51 | + * |
| 52 | + * @param ComparableType $right |
| 53 | + * @param bool $insertParentheses |
| 54 | + * @return GreaterThanOrEqual |
| 55 | + */ |
| 56 | + public function gte(ComparableType $right, bool $insertParentheses = true): GreaterThanOrEqual |
| 57 | + { |
| 58 | + return new GreaterThanOrEqual($this, $right, $insertParentheses); |
| 59 | + } |
| 60 | + |
| 61 | + /** |
| 62 | + * Perform a less than comparison against the given expression. |
| 63 | + * |
| 64 | + * @param ComparableType $right |
| 65 | + * @param bool $insertParentheses |
| 66 | + * @return LessThan |
| 67 | + */ |
| 68 | + public function lt(ComparableType $right, bool $insertParentheses = true): LessThan |
| 69 | + { |
| 70 | + return new LessThan($this, $right, $insertParentheses); |
| 71 | + } |
| 72 | + |
| 73 | + /** |
| 74 | + * Perform a less than or equal comparison against the given expression. |
| 75 | + * |
| 76 | + * @param ComparableType $right |
| 77 | + * @param bool $insertParentheses |
| 78 | + * @return LessThanOrEqual |
| 79 | + */ |
| 80 | + public function lte(ComparableType $right, bool $insertParentheses = true): LessThanOrEqual |
| 81 | + { |
| 82 | + return new LessThanOrEqual($this, $right, $insertParentheses); |
| 83 | + } |
| 84 | +} |
0 commit comments