本文整理匯總了PHP中Faker\Generator::regexify方法的典型用法代碼示例。如果您正苦於以下問題:PHP Generator::regexify方法的具體用法?PHP Generator::regexify怎麽用?PHP Generator::regexify使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Faker\Generator
的用法示例。
在下文中一共展示了Generator::regexify方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: handleString
/**
* Generate a string
*
* @param $schema
* @param $required
* @param null $property
* @return null|string
* @throws InvalidArgumentException
*/
private function handleString($schema, $required, $property = null)
{
if (!$this->shouldHandle($required)) {
return null;
}
$enum = $this->getEnum($schema);
if (null !== $enum) {
return $enum;
}
if ($this->provider->hasProperty($schema, 'pattern')) {
$pattern = $this->provider->getProperty($schema, 'pattern');
return $this->generator->regexify($pattern);
}
if ($this->hasFormatter($schema, $property)) {
$formatter = $this->getFormatter($schema, $property);
return $formatter();
}
$maxLength = $this->provider->getProperty($schema, 'maxLength', $this->config->getMaxLength());
$minLength = $this->provider->getProperty($schema, 'minLength', $this->config->getMinLength());
$text = $this->generator->text($maxLength);
while (strlen($text) < $minLength) {
$text .= $this->generator->randomLetter;
}
return $text;
}