This commit is contained in:
Darko Gjorgjijoski
2024-07-13 15:19:00 +02:00
parent 429a8ae826
commit e212714c63

View File

@@ -46,7 +46,7 @@ class EnvironmentManager
*/ */
public function updateEnv(array $data) public function updateEnv(array $data)
{ {
if (empty($data) || !is_array($data) || !is_file($this->envPath)) { if (empty($data) || ! is_array($data) || ! is_file($this->envPath)) {
return false; return false;
} }
@@ -62,14 +62,14 @@ class EnvironmentManager
// Check if new or old key // Check if new or old key
if ($entry[0] == $data_key) { if ($entry[0] == $data_key) {
$env[$env_key] = $data_key . '=' . $this->encode($data_value); $env[$env_key] = $data_key.'='.$this->encode($data_value);
$updated = true; $updated = true;
} }
} }
// Lets create if not available // Lets create if not available
if (!$updated) { if (! $updated) {
$env[] = $data_key . '=' . $this->encode($data_value); $env[] = $data_key.'='.$this->encode($data_value);
} }
} }
@@ -88,8 +88,8 @@ class EnvironmentManager
private function encode($str) private function encode($str)
{ {
if ((strpos($str, ' ') !== false || preg_match('/' . preg_quote('^\'£$%^&*()}{@#~?><,@|-=-_+-¬', '/') . '/', $str)) && ($str[0] != '"' || $str[strlen($str) - 1] != '"')) { if ((strpos($str, ' ') !== false || preg_match('/'.preg_quote('^\'£$%^&*()}{@#~?><,@|-=-_+-¬', '/').'/', $str)) && ($str[0] != '"' || $str[strlen($str) - 1] != '"')) {
$str = '"' . $str . '"'; $str = '"'.$str.'"';
} }
return $str; return $str;
@@ -124,7 +124,7 @@ class EnvironmentManager
// https://laravel.com/docs/11.x/database#introduction // https://laravel.com/docs/11.x/database#introduction
if (extension_loaded('sqlite3') && class_exists('\SQLite3') && method_exists('\SQLite3', 'version')) { if (extension_loaded('sqlite3') && class_exists('\SQLite3') && method_exists('\SQLite3', 'version')) {
$version = \SQLite3::version(); $version = \SQLite3::version();
if (!empty($version['versionString']) && version_compare($version['versionString'], '3.35.0', '<')) { if (! empty($version['versionString']) && version_compare($version['versionString'], '3.35.0', '<')) {
return [ return [
'error_message' => sprintf('The minimum SQLite version is %s. Your current SQLite version is %s which is not supported. Please upgrade SQLite and retry.', '3.35.0', $version['versionString']), 'error_message' => sprintf('The minimum SQLite version is %s. Your current SQLite version is %s which is not supported. Please upgrade SQLite and retry.', '3.35.0', $version['versionString']),
]; ];
@@ -135,13 +135,13 @@ class EnvironmentManager
]; ];
} }
$dbEnv['DB_DATABASE'] = $request->get('database_name'); $dbEnv['DB_DATABASE'] = $request->get('database_name');
if (!empty($dbEnv['DB_DATABASE'])) { if (! empty($dbEnv['DB_DATABASE'])) {
$sqlite_path = $dbEnv['DB_DATABASE']; $sqlite_path = $dbEnv['DB_DATABASE'];
} else { } else {
$sqlite_path = database_path('database.sqlite'); $sqlite_path = database_path('database.sqlite');
} }
// Create empty SQLite database if it doesn't exist. // Create empty SQLite database if it doesn't exist.
if (!file_exists($sqlite_path)) { if (! file_exists($sqlite_path)) {
copy(database_path('stubs/sqlite.empty.db'), $sqlite_path); copy(database_path('stubs/sqlite.empty.db'), $sqlite_path);
$dbEnv['DB_DATABASE'] = $sqlite_path; $dbEnv['DB_DATABASE'] = $sqlite_path;
} }
@@ -237,7 +237,7 @@ class EnvironmentManager
/** /**
* Returns the mail configuration * Returns the mail configuration
* *
* @param MailEnvironmentRequest $request * @param MailEnvironmentRequest $request
* @return array * @return array
*/ */
private function getMailConfiguration($request) private function getMailConfiguration($request)
@@ -444,7 +444,7 @@ class EnvironmentManager
if ($parts_line[0] != $parts_last[0]) { if ($parts_line[0] != $parts_last[0]) {
$formatted .= $this->delimiter; $formatted .= $this->delimiter;
} }
$formatted .= $current . $this->delimiter; $formatted .= $current.$this->delimiter;
$previous = $current; $previous = $current;
} }