Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F6059711
RegexGenerator.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
RegexGenerator.php
View Options
<?php
namespace
Eris\Generator
;
use
BadFunctionCallException
;
use
Eris\Generator
;
use
Eris\Generators
;
use
Eris\Random\RandomRange
;
use
ReverseRegex\Lexer
;
use
ReverseRegex\Random\SimpleRandom
;
use
ReverseRegex\Parser
;
use
ReverseRegex\Generator\Scope
;
/**
* Note * and + modifiers cause an unbounded number of character to be generated
* (up to plus infinity) and as such they are not supported.
* Please use {1,N} and {0,N} instead of + and *.
*
* @param string $expression
* @return Generator\RegexGenerator
*/
function
regex
(
$expression
)
{
return
Generators
::
regex
(
$expression
);
}
/**
* @template-implements Generator<string>
*/
class
RegexGenerator
implements
Generator
{
private
$expression
;
public
function
__construct
(
$expression
)
{
if
(!
class_exists
(
"ReverseRegex
\P
arser"
))
{
throw
new
BadFunctionCallException
(
"Please install the suggested dependency icomefromthenet/reverse-regex to run this Generator."
);
}
$this
->
expression
=
$expression
;
}
public
function
__invoke
(
$_size
,
RandomRange
$rand
)
{
$lexer
=
new
Lexer
(
$this
->
expression
);
$gen
=
new
SimpleRandom
(
$rand
->
rand
());
$result
=
null
;
$parser
=
new
Parser
(
$lexer
,
new
Scope
(),
new
Scope
());
$parser
->
parse
()->
getResult
()->
generate
(
$result
,
$gen
);
return
GeneratedValueSingle
::
fromJustValue
(
$result
,
'regex'
);
}
public
function
shrink
(
GeneratedValue
$value
)
{
return
$value
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Oct 5 2026, 02:18 (5 w, 6 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
ad/4e/60bef78640d82976af394a9046c8
Default Alt Text
RegexGenerator.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment