/** * * @param PhpFile $content * @param string $tableName */ private function writeFile(PhpFile $content, $tableName) { $fileName = StringHelper::toPascalCase($tableName) . ".php"; $dirName = empty($this->destDirDb) ? '' : $this->destDirDb . DIRECTORY_SEPARATOR; $fullFileName = $this->destDirRoot . DIRECTORY_SEPARATOR . $dirName . $fileName; $fullDirName = dirname($fullFileName); if (!is_dir($fullDirName)) { mkdir($fullDirName, 0777, true); } touch($fullFileName); file_put_contents($fullFileName, (string) $content); }
/** * * @param array $values * @return mixed[] * @throws PhpExcelException */ private function formatValues(array $values) { $formattedValues = []; foreach ($values as $name => $value) { $originalFieldName = $this->loweredToOriginalKeysMap[$name]; $type = $this->loweredFields[$name]; if ($type & ExcelFieldType::REQUIRED) { if (strlen($value) < 1) { throw new PhpExcelException("Required column '{$originalFieldName}' is empty"); } $type = $type ^ ExcelFieldType::REQUIRED; } if (strlen($value) < 1) { $formattedValues[$originalFieldName] = null; continue; } switch ($type) { case ExcelFieldType::DATE: $value = $this->getValueAsDate($value, $originalFieldName); break; case ExcelFieldType::INT: $value = $this->getValueAsInt($value, $originalFieldName); break; case ExcelFieldType::FLOAT: $value = $this->getValueAsFloat($value, $originalFieldName); break; } $formattedValues[$originalFieldName] = is_object($value) ? $value : StringHelper::safeTrim($value); } return $formattedValues; }