classLiteralGenerator
final class LiteralGenerator
Generates MySql literal bodies for the bounded lexical API.
Owns the alphabets and numeric formatting used by this dialect.
Methods§
public function __construct(Generator $faker)Parameters
$faker | Generator | Source of every choice the generated strings make |
Calls 1
public function rawIdentifier(int $minLength = 1, int $maxLength = 12): stringGenerate a raw SQL identifier (starts with letter or underscore, followed by alphanumeric/underscore).
Parameters
$minLength | int | |
$maxLength | int |
Returns
stringTest cases 4
Called from 1
Calls 6
- method-call
Generator::numberBetween()line 46 - function-call
maxline 46 - method-call RandomCharacters::character() line 48
- class-const LiteralGenerator::ALPHA_UNDERSCORE() line 48
- method-call RandomCharacters::string() line 49
- class-const LiteralGenerator::ALNUM_UNDERSCORE() line 49
public function mixedAlnumString(int $minLength = 1, int $maxLength = 24): stringGenerate a random string from the mixed alphanumeric+underscore alphabet.
Parameters
$minLength | int | |
$maxLength | int |
Returns
stringTest cases 4
Called from 2
Calls 3
- method-call RandomCharacters::string() line 57
- class-const LiteralGenerator::MIXED_ALNUM_UNDERSCORE() line 57
- method-call
Generator::numberBetween()line 57
public function integerString(int $min = 1, int $max = 9999999999): non-empty-stringGenerate a random integer literal string.
Parameters
$min | int | |
$max | int |
Returns
non-empty-stringTest cases 4
Called from 1
Calls 1
- method-call
Generator::numberBetween()line 67
public function hexString(int $minLength = 1, int $maxLength = 16): stringGenerate a random hexadecimal string.
Parameters
$minLength | int | |
$maxLength | int |
Returns
stringTest cases 4
Called from 2
Calls 3
- method-call RandomCharacters::string() line 75
- class-const LiteralGenerator::HEX_CHARS() line 75
- method-call
Generator::numberBetween()line 75
public function binaryString(int $minLength = 1, int $maxLength = 32): stringGenerate a random binary string (0s and 1s).
Parameters
$minLength | int | |
$maxLength | int |
Returns
stringTest cases 4
Called from 1
Calls 3
- method-call RandomCharacters::string() line 83
- class-const LiteralGenerator::BINARY_CHARS() line 83
- method-call
Generator::numberBetween()line 83
public function decimalString(int $precision = 13, int $scale = 6): non-empty-stringGenerate a random decimal literal string.
Parameters
$precision | int | |
$scale | int |
Returns
non-empty-stringTest cases 7
LiteralGeneratorTest::testDecimalStringCustomPrecisioncallsLiteralGeneratorTest::testDecimalStringDefaultMatchesExplicitcallsLiteralGeneratorTest::testDecimalStringFormatcallsLiteralGeneratorTest::testDecimalStringFracDigitsMatchScalecallsLiteralGeneratorTest::testDecimalStringPrecisionLimitsIntPartDigitscallsLiteralGeneratorTest::testDecimalStringWithEqualPrecisionAndScalecallsLiteralGeneratorTest::testDecimalStringWithScaleOneHasTwoFracDigitscalls
Called from 1
public function hostnameString(
int $minParts = 1,
int $maxParts = 3,
int $minPartLength = 1,
int $maxPartLength = 12,
): non-empty-stringGenerate a random hostname string.
Parameters
$minParts | int | |
$maxParts | int | |
$minPartLength | int | |
$maxPartLength | int |
Returns
non-empty-stringThrows
LogicException When the requested bounds leave every part of the hostname emptyTest cases 3
Called from 1
Calls 5
- method-call
Generator::numberBetween()line 112 - method-call RandomCharacters::string() line 115
- class-const LiteralGenerator::HOSTNAME_CHARS() line 115
- function-call
implodeline 118 - new
LogicExceptionline 120
public function unsignedBigIntString(int $minLength = 1, int $maxLength = 20): non-empty-stringGenerate a random unsigned big integer string.
Parameters
$minLength | int | |
$maxLength | int |
Returns
non-empty-stringTest cases 4
Called from 1
Calls 4
- method-call RandomCharacters::string() line 133
- class-const LiteralGenerator::DIGIT_CHARS() line 133
- method-call
Generator::numberBetween()line 133 - function-call
ltrimline 134
public function longIntString(int $min = 0, int $max = 2147483647): non-empty-stringGenerate a random long integer string.
Parameters
$min | int | |
$max | int |
Returns
non-empty-stringTest cases 2
Called from 1
Calls 1
- method-call
Generator::numberBetween()line 146
public function floatString(
string $mantissa,
int $minExponent = -20,
int $maxExponent = 20,
): non-empty-stringGenerate a random float literal string with exponent.
Parameters
$mantissa | string | |
$minExponent | int | |
$maxExponent | int |
Returns
non-empty-stringTest cases 2
Called from 1
Calls 1
- method-call
Generator::numberBetween()line 158
Private surface 9§
Implementation details, listed for orientation only.
private const ALPHA_UNDERSCORE = 'abcdefghijklmnopqrstuvwxyz_'private const ALNUM_UNDERSCORE = 'abcdefghijklmnopqrstuvwxyz0123456789_'private const MIXED_ALNUM_UNDERSCORE = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_'private const HOSTNAME_CHARS = 'abcdefghijklmnopqrstuvwxyz0123456789'private const HEX_CHARS = '0123456789abcdef'private const DIGIT_CHARS = '0123456789'private const BINARY_CHARS = '01'private Generator $fakerprivate RandomCharacters $charactersTest cases 43§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 38
LiteralGeneratorTest::testBinaryStringCustomLengthcallsLiteralGeneratorTest::testBinaryStringDefaultMatchesExplicitcallsLiteralGeneratorTest::testBinaryStringFormatcallsLiteralGeneratorTest::testBinaryStringLengthRangecallsLiteralGeneratorTest::testDecimalStringCustomPrecisioncallsLiteralGeneratorTest::testDecimalStringDefaultMatchesExplicitcallsLiteralGeneratorTest::testDecimalStringFormatcallsLiteralGeneratorTest::testDecimalStringFracDigitsMatchScalecallsLiteralGeneratorTest::testDecimalStringPrecisionLimitsIntPartDigitscallsLiteralGeneratorTest::testDecimalStringWithEqualPrecisionAndScalecallsLiteralGeneratorTest::testDecimalStringWithScaleOneHasTwoFracDigitscallsLiteralGeneratorTest::testFloatStringCustomExponentcallsLiteralGeneratorTest::testFloatStringDefaultMatchesExplicitcallsLiteralGeneratorTest::testHexStringCustomLengthcallsLiteralGeneratorTest::testHexStringDefaultMatchesExplicitcallsLiteralGeneratorTest::testHexStringFormatcallsLiteralGeneratorTest::testHexStringLengthRangecallsLiteralGeneratorTest::testHostnameStringCustomPartscallsLiteralGeneratorTest::testHostnameStringDefaultMatchesExplicitcallsLiteralGeneratorTest::testHostnameStringFormatcallsLiteralGeneratorTest::testIntegerStringCustomRangecallsLiteralGeneratorTest::testIntegerStringDefaultMatchesExplicitcallsLiteralGeneratorTest::testIntegerStringDigitCountRangecallsLiteralGeneratorTest::testIntegerStringFormatcallsLiteralGeneratorTest::testLongIntStringCustomRangecallsLiteralGeneratorTest::testLongIntStringDefaultMatchesExplicitcallsLiteralGeneratorTest::testMixedAlnumStringCharacterSetcallsLiteralGeneratorTest::testMixedAlnumStringCustomLengthcallsLiteralGeneratorTest::testMixedAlnumStringDefaultMatchesExplicitcallsLiteralGeneratorTest::testMixedAlnumStringLengthRangecallsLiteralGeneratorTest::testRawIdentifierCustomLengthcallsLiteralGeneratorTest::testRawIdentifierDefaultMatchesExplicitcallsLiteralGeneratorTest::testRawIdentifierLengthRangecallsLiteralGeneratorTest::testRawIdentifierStartsWithLetterOrUnderscorecallsLiteralGeneratorTest::testUnsignedBigIntStringCustomLengthcallsLiteralGeneratorTest::testUnsignedBigIntStringDefaultMatchesExplicitcallsLiteralGeneratorTest::testUnsignedBigIntStringFormatcallsLiteralGeneratorTest::testUnsignedBigIntStringLengthRangecalls
Other tests reaching this symbol 5
LexicalExceptionTestcallsGenerationContextTestcallsLexicalGrammarTestcallsSqlGeneratorFactoryTestcallsMySqlProviderTestcalls
Relations§
Instantiated in 1
Method calls 12
- method-call SqlFaker\MySql\Generation\LexicalGrammar::generateQuotedIdentifier() packages/sql-faker/src/MySql/Generation/LexicalGrammar.php:153
- method-call SqlFaker\MySql\Generation\LexicalGrammar::generateStringLiteral() packages/sql-faker/src/MySql/Generation/LexicalGrammar.php:166
- method-call SqlFaker\MySql\Generation\LexicalGrammar::generateDollarQuotedString() packages/sql-faker/src/MySql/Generation/LexicalGrammar.php:192
- method-call SqlFaker\MySql\Generation\LexicalGrammar::generateIntegerLiteral() packages/sql-faker/src/MySql/Generation/LexicalGrammar.php:205
- method-call SqlFaker\MySql\Generation\LexicalGrammar::generateLongIntegerLiteral() packages/sql-faker/src/MySql/Generation/LexicalGrammar.php:218
- method-call SqlFaker\MySql\Generation\LexicalGrammar::generateUnsignedBigIntLiteral() packages/sql-faker/src/MySql/Generation/LexicalGrammar.php:231
- method-call SqlFaker\MySql\Generation\LexicalGrammar::generateDecimalLiteral() packages/sql-faker/src/MySql/Generation/LexicalGrammar.php:244
- method-call SqlFaker\MySql\Generation\LexicalGrammar::generateFloatLiteral() packages/sql-faker/src/MySql/Generation/LexicalGrammar.php:263
- method-call SqlFaker\MySql\Generation\LexicalGrammar::generateHexLiteral() packages/sql-faker/src/MySql/Generation/LexicalGrammar.php:280
- method-call SqlFaker\MySql\Generation\LexicalGrammar::generateQuotedHexLiteral() packages/sql-faker/src/MySql/Generation/LexicalGrammar.php:295
- method-call SqlFaker\MySql\Generation\LexicalGrammar::generateBinaryLiteral() packages/sql-faker/src/MySql/Generation/LexicalGrammar.php:308
- method-call SqlFaker\MySql\Generation\LexicalGrammar::generateHostname() packages/sql-faker/src/MySql/Generation/LexicalGrammar.php:322