-
Notifications
You must be signed in to change notification settings - Fork 1
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
Showing
5 changed files
with
207 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace MariaStan\Database\FunctionInfo; | ||
|
||
use MariaStan\Analyser\AnalyserConditionTypeEnum; | ||
use MariaStan\Analyser\ExprTypeResult; | ||
use MariaStan\Ast\Expr\FunctionCall\FunctionCall; | ||
use MariaStan\Parser\Exception\ParserException; | ||
use MariaStan\Schema\DbType\VarcharType; | ||
|
||
use function count; | ||
|
||
final class LowerUpper implements FunctionInfo | ||
{ | ||
/** @inheritDoc */ | ||
public function getSupportedFunctionNames(): array | ||
{ | ||
return ['LOWER', 'LCASE', 'UPPER', 'UCASE']; | ||
} | ||
|
||
public function getFunctionType(): FunctionTypeEnum | ||
{ | ||
return FunctionTypeEnum::SIMPLE; | ||
} | ||
|
||
public function checkSyntaxErrors(FunctionCall $functionCall): void | ||
{ | ||
$args = $functionCall->getArguments(); | ||
$argCount = count($args); | ||
|
||
if ($argCount === 1) { | ||
return; | ||
} | ||
|
||
throw new ParserException( | ||
FunctionInfoHelper::createArgumentCountErrorMessageFixed( | ||
$functionCall->getFunctionName(), | ||
1, | ||
$argCount, | ||
), | ||
); | ||
} | ||
|
||
/** @inheritDoc */ | ||
public function getInnerConditions(?AnalyserConditionTypeEnum $condition, array $arguments): array | ||
{ | ||
return [$condition]; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
* @phpcsSuppress SlevomatCodingStandard.Functions.UnusedParameter | ||
*/ | ||
public function getReturnType( | ||
FunctionCall $functionCall, | ||
array $argumentTypes, | ||
?AnalyserConditionTypeEnum $condition, | ||
): ExprTypeResult { | ||
$arg = $argumentTypes[0]; | ||
|
||
return new ExprTypeResult( | ||
new VarcharType(), | ||
$arg->isNullable, | ||
null, | ||
$arg->knowledgeBase, | ||
); | ||
} | ||
} |
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