-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5fcba17
commit df9b4f6
Showing
5 changed files
with
154 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<?php declare(strict_types=1); | ||
/** | ||
* Form | ||
* | ||
* Useful class for manipulate form | ||
* | ||
* PHP version 8.1.2 | ||
* | ||
* @package kzarshenas/crazyphp | ||
* @author kekefreedog <kevin.zarshenas@gmail.com> | ||
* @copyright 2022-2024 Kévin Zarshenas | ||
*/ | ||
namespace CrazyPHP\Library\Database\Operation; | ||
|
||
/** | ||
* Dependances | ||
*/ | ||
use CrazyPHP\Library\Form\Operation; | ||
use MongoDB\BSON\Regex; | ||
|
||
/** | ||
* Process operations in string | ||
* | ||
* Parse operations into string | ||
* | ||
* @package kzarshenas/crazyphp | ||
* @author kekefreedog <kevin.zarshenas@gmail.com> | ||
* @copyright 2022-2024 Kévin Zarshenas | ||
*/ | ||
class MangodbOperation extends Operation { | ||
|
||
/** | ||
* Constructor | ||
* | ||
* Construct and prepare instance | ||
* | ||
* @param string|array $Operation Exemple ["=", "[]"] or ["contains", "between"] or "@>" or "contains" or "*" (for all operations) | ||
* @return self | ||
*/ | ||
public function __construct(string|array $operations = ["*"]){ | ||
|
||
# Parent | ||
parent::__construct($operations); | ||
|
||
} | ||
|
||
/** Public parameters | Operations | ||
****************************************************** | ||
*/ | ||
|
||
/** | ||
* Like | ||
* | ||
* Exemple : `*value` | ||
* Description : Performs a pattern match (like SQL's LIKE) | ||
* | ||
* @param string|array $input | ||
* @param array $operation | ||
* @return mixed | ||
*/ | ||
public function parseLike(string|array $input, array $operation):mixed { | ||
|
||
# Set result of parent | ||
$parentResult = parent::parseLike($input, $operation); | ||
|
||
# Regex result | ||
/** @disregard P1009 Assume $regex = MongoDB\BSON\Regex is available */ | ||
$regexResult = new Regex($parentResult["value"][1], 'i'); | ||
|
||
# Return regex result | ||
return $regexResult; | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters