for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace MartinGeorgiev\Doctrine\ORM\Query\AST\Functions;
use Doctrine\ORM\Query\AST\Node;
use MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\Exception\InvalidArgumentForVariadicFunctionException;
/**
* Implementation of PostgreSQL REGEXP_REPLACE().
*
* @see https://www.postgresql.org/docs/15/functions-matching.html#FUNCTIONS-POSIX-REGEXP
* @since 2.5
* @author Colin Doig
*/
class RegexpReplace extends BaseVariadicFunction
{
protected function customizeFunction(): void
$this->setFunctionPrototype('regexp_replace(%s)');
}
protected function validateArguments(Node ...$arguments): void
$argumentCount = \count($arguments);
if ($argumentCount < 2 || $argumentCount > 5) {
throw InvalidArgumentForVariadicFunctionException::between('regexp_substr', 2, 5);
if ($argumentCount === 4) {
throw InvalidArgumentForVariadicFunctionException::unsupportedCombination('regexp_substr', 4, 'start and N parameter shall be used together');