Definition at line 12 of file DataGenerator.php.
◆ __construct()
__construct |
( |
|
$dictionaryFile | ) |
|
DataGenerator constructor.
- Parameters
-
Definition at line 40 of file DataGenerator.php.
42 $this->dictionaryFile = $dictionaryFile;
44 $this->generatedValues = [];
◆ generate()
generate |
( |
|
$minAmountOfWords, |
|
|
|
$maxAmountOfWords, |
|
|
|
$key = null |
|
) |
| |
Generate string of random word data.
- Parameters
-
int | $minAmountOfWords | |
int | $maxAmountOfWords | |
string | null | $key | |
- Returns
- string
Definition at line 68 of file DataGenerator.php.
70 $numberOfWords = random_int($minAmountOfWords, $maxAmountOfWords);
73 if ($key ===
null || !array_key_exists($key, $this->generatedValues)) {
74 for (
$i = 0;
$i < $numberOfWords;
$i++) {
75 $result .=
' ' . $this->dictionaryData[random_int(0, count($this->dictionaryData) - 1)];
80 $this->generatedValues[$key] =
$result;
83 $result = $this->generatedValues[$key];
◆ readData()
Read data from file.
- Returns
- void
Definition at line 52 of file DataGenerator.php.
54 $f =
fopen($this->dictionaryFile,
'r');
55 while (!
feof($f) && is_array($line = fgetcsv($f))) {
56 $this->dictionaryData[] = $line[0];
The documentation for this class was generated from the following file: