mirror of
https://github.com/crater-invoice/crater.git
synced 2025-10-28 04:01:10 -04:00
Implement PHP CS Fixer and a coding standard to follow (#471)
* Create PHP CS Fixer config and add to CI workflow * Run php cs fixer on project * Add newline at end of file * Update to use PHP CS Fixer v3 * Run v3 config on project * Run seperate config in CI
This commit is contained in:
@ -1,10 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace Crater\Space;
|
||||
|
||||
use File;
|
||||
use Artisan;
|
||||
use GuzzleHttp\Exception\RequestException;
|
||||
use Crater\Events\UpdateFinished;
|
||||
use File;
|
||||
use GuzzleHttp\Exception\RequestException;
|
||||
use ZipArchive;
|
||||
|
||||
// Implementation taken from Akaunting - https://github.com/akaunting/akaunting
|
||||
@ -15,11 +16,10 @@ class Updater
|
||||
public static function checkForUpdate($installed_version)
|
||||
{
|
||||
$data = null;
|
||||
if(env('APP_ENV') === 'development')
|
||||
{
|
||||
$url = 'downloads/check/latest/'. $installed_version . '?type=update&is_dev=1';
|
||||
if (env('APP_ENV') === 'development') {
|
||||
$url = 'downloads/check/latest/'.$installed_version.'?type=update&is_dev=1';
|
||||
} else {
|
||||
$url = 'downloads/check/latest/'. $installed_version . '?type=update';
|
||||
$url = 'downloads/check/latest/'.$installed_version.'?type=update';
|
||||
}
|
||||
|
||||
$response = static::getRemote($url, ['timeout' => 100, 'track_redirects' => true]);
|
||||
@ -36,7 +36,7 @@ class Updater
|
||||
foreach (json_decode($extensions) as $extension) {
|
||||
$extensionData[$extension] = phpversion($extension) ? true : false;
|
||||
}
|
||||
$extensionData['php'. '('.$data->version->minimum_php_version.')'] = version_compare(phpversion(), $data->version->minimum_php_version, ">=");
|
||||
$extensionData['php'.'('.$data->version->minimum_php_version.')'] = version_compare(phpversion(), $data->version->minimum_php_version, ">=");
|
||||
$data->version->extensions = $extensionData;
|
||||
}
|
||||
|
||||
@ -49,9 +49,9 @@ class Updater
|
||||
$path = null;
|
||||
|
||||
if (env('APP_ENV') === 'development') {
|
||||
$url = 'downloads/file/' . $new_version . '?type=update&is_dev=1&is_cmd='. $is_cmd;
|
||||
$url = 'downloads/file/'.$new_version.'?type=update&is_dev=1&is_cmd='.$is_cmd;
|
||||
} else {
|
||||
$url = 'downloads/file/' . $new_version . '?type=update&is_cmd='. $is_cmd;
|
||||
$url = 'downloads/file/'.$new_version.'?type=update&is_cmd='.$is_cmd;
|
||||
}
|
||||
|
||||
$response = static::getRemote($url, ['timeout' => 100, 'track_redirects' => true]);
|
||||
@ -62,8 +62,8 @@ class Updater
|
||||
'success' => false,
|
||||
'error' => 'Download Exception',
|
||||
'data' => [
|
||||
'path' => $path
|
||||
]
|
||||
'path' => $path,
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
@ -72,18 +72,18 @@ class Updater
|
||||
}
|
||||
|
||||
// Create temp directory
|
||||
$temp_dir = storage_path('app/temp-' . md5(mt_rand()));
|
||||
$temp_dir = storage_path('app/temp-'.md5(mt_rand()));
|
||||
|
||||
if (!File::isDirectory($temp_dir)) {
|
||||
if (! File::isDirectory($temp_dir)) {
|
||||
File::makeDirectory($temp_dir);
|
||||
}
|
||||
|
||||
$zip_file_path = $temp_dir . '/upload.zip';
|
||||
$zip_file_path = $temp_dir.'/upload.zip';
|
||||
|
||||
// Add content to the Zip file
|
||||
$uploaded = is_int(file_put_contents($zip_file_path, $data)) ? true : false;
|
||||
|
||||
if (!$uploaded) {
|
||||
if (! $uploaded) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -92,13 +92,13 @@ class Updater
|
||||
|
||||
public static function unzip($zip_file_path)
|
||||
{
|
||||
if(!file_exists($zip_file_path)) {
|
||||
if (! file_exists($zip_file_path)) {
|
||||
throw new \Exception('Zip file not found');
|
||||
}
|
||||
|
||||
$temp_extract_dir = storage_path('app/temp2-' . md5(mt_rand()));
|
||||
$temp_extract_dir = storage_path('app/temp2-'.md5(mt_rand()));
|
||||
|
||||
if (!File::isDirectory($temp_extract_dir)) {
|
||||
if (! File::isDirectory($temp_extract_dir)) {
|
||||
File::makeDirectory($temp_extract_dir);
|
||||
}
|
||||
// Unzip the file
|
||||
@ -118,7 +118,7 @@ class Updater
|
||||
|
||||
public static function copyFiles($temp_extract_dir)
|
||||
{
|
||||
if (!File::copyDirectory($temp_extract_dir . '/Crater', base_path())) {
|
||||
if (! File::copyDirectory($temp_extract_dir.'/Crater', base_path())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -132,7 +132,7 @@ class Updater
|
||||
{
|
||||
$files = json_decode($json);
|
||||
|
||||
foreach($files as $file) {
|
||||
foreach ($files as $file) {
|
||||
\File::delete(base_path($file));
|
||||
}
|
||||
|
||||
@ -153,7 +153,7 @@ class Updater
|
||||
return [
|
||||
'success' => true,
|
||||
'error' => false,
|
||||
'data' => []
|
||||
'data' => [],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user