16 private $dictionaryFilePath;
29 $this->dictionaryFilePath = $dictionaryFilePath;
39 if ($this->dictionary ===
null) {
40 $this->readDictionary();
43 $randIndex = random_int(0, count($this->dictionary) - 1);
44 return trim($this->dictionary[$randIndex]);
53 private function readDictionary()
56 throw new \Magento\Setup\Exception(
57 sprintf(
'Description file %s not found or is not readable', $this->dictionaryFilePath)
61 $rows = file($this->dictionaryFilePath, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
63 if ($rows ===
false) {
64 throw new \Magento\Setup\Exception(
65 sprintf(
'Error occurred while reading dictionary file %s', $this->dictionaryFilePath)
70 throw new \Magento\Setup\Exception(
71 sprintf(
'Dictionary file %s is empty', $this->dictionaryFilePath)
75 $this->dictionary = \SplFixedArray::fromArray($rows);
__construct($dictionaryFilePath)