Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 34 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| CommandFactory | |
0.00% |
0 / 34 |
|
0.00% |
0 / 1 |
342 | |
0.00% |
0 / 1 |
| createCommand | |
0.00% |
0 / 34 |
|
0.00% |
0 / 1 |
342 | |||
| 1 | <?php |
| 2 | |
| 3 | /* |
| 4 | * This program is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU General Public License |
| 6 | * as published by the Free Software Foundation; under version 2 |
| 7 | * of the License (non-upgradable). |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 17 | * |
| 18 | * Copyright (c) 2023 (original work) Open Assessment Technologies SA; |
| 19 | * |
| 20 | */ |
| 21 | |
| 22 | namespace oat\generis\model\kernel\persistence\starsql\search\Command; |
| 23 | |
| 24 | use oat\search\helper\SupportedOperatorHelper; |
| 25 | use WikibaseSolutions\CypherDSL\Expressions\Operators; |
| 26 | |
| 27 | class CommandFactory |
| 28 | { |
| 29 | public static function createCommand(string $operator): CommandInterface |
| 30 | { |
| 31 | switch ($operator) { |
| 32 | case SupportedOperatorHelper::DIFFERENT: |
| 33 | return new NotCommandWrapper( |
| 34 | new ConfigurableCommand(Operators\Equality::class) |
| 35 | ); |
| 36 | case SupportedOperatorHelper::GREATER_THAN: |
| 37 | return new ConfigurableCommand(Operators\GreaterThan::class); |
| 38 | case SupportedOperatorHelper::LESSER_THAN: |
| 39 | return new ConfigurableCommand(Operators\LessThan::class); |
| 40 | case SupportedOperatorHelper::GREATER_THAN_EQUAL: |
| 41 | return new ConfigurableCommand(Operators\GreaterThanOrEqual::class); |
| 42 | case SupportedOperatorHelper::LESSER_THAN_EQUAL: |
| 43 | return new ConfigurableCommand(Operators\LessThanOrEqual::class); |
| 44 | case SupportedOperatorHelper::MATCH: |
| 45 | return new RegexCommand(); |
| 46 | case SupportedOperatorHelper::NOT_MATCH: |
| 47 | return new NotCommandWrapper(new RegexCommand()); |
| 48 | case SupportedOperatorHelper::IN: |
| 49 | return new ConfigurableCommand(Operators\In::class); |
| 50 | case SupportedOperatorHelper::NOT_IN: |
| 51 | return new NotCommandWrapper(new ConfigurableCommand(Operators\In::class)); |
| 52 | case SupportedOperatorHelper::BETWEEN: |
| 53 | return new BetweenCommand(); |
| 54 | case SupportedOperatorHelper::CONTAIN: |
| 55 | return new RegexCommand(true, true); |
| 56 | case SupportedOperatorHelper::BEGIN_BY: |
| 57 | return new RegexCommand(false, true); |
| 58 | case SupportedOperatorHelper::ENDING_BY: |
| 59 | return new RegexCommand(true, false); |
| 60 | case SupportedOperatorHelper::IS_NULL: |
| 61 | return new ConfigurableCommand(Operators\IsNull::class); |
| 62 | case SupportedOperatorHelper::IS_NOT_NULL: |
| 63 | return new ConfigurableCommand(Operators\IsNotNull::class); |
| 64 | case SupportedOperatorHelper::EQUAL: |
| 65 | default: |
| 66 | return new ConfigurableCommand(Operators\Equality::class); |
| 67 | } |
| 68 | } |
| 69 | } |