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:
Mwikala Kangwa
2021-05-21 12:57:51 +01:00
committed by GitHub
parent 633cad9b89
commit 9e98a96d61
316 changed files with 4715 additions and 3195 deletions

View File

@ -3,18 +3,17 @@
namespace Crater\Models;
use Crater\Carbon;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class FileDisk extends Model
{
CONST DISK_TYPE_SYSTEM = 'SYSTEM';
CONST DISK_TYPE_REMOTE = 'REMOTE';
use HasFactory;
public const DISK_TYPE_SYSTEM = 'SYSTEM';
public const DISK_TYPE_REMOTE = 'REMOTE';
protected $guarded = [
'id'
'id',
];
public function setCredentialsAttribute($value)
@ -22,12 +21,12 @@ class FileDisk extends Model
$this->attributes['credentials'] = json_encode($value);
}
public function scopeWhereOrder($query, $orderByField, $orderBy)
public function scopeWhereOrder($query, $orderByField, $orderBy)
{
$query->orderBy($orderByField, $orderBy);
}
public function scopeFileDisksBetween($query, $start, $end)
public function scopeFileDisksBetween($query, $start, $end)
{
return $query->whereBetween(
'file_disks.created_at',
@ -38,8 +37,8 @@ class FileDisk extends Model
public function scopeWhereSearch($query, $search)
{
foreach (explode(' ', $search) as $term) {
$query->where('name', 'LIKE', '%' . $term . '%')
->orWhere('driver', 'LIKE', '%' . $term . '%');
$query->where('name', 'LIKE', '%'.$term.'%')
->orWhere('driver', 'LIKE', '%'.$term.'%');
}
}
@ -48,6 +47,7 @@ class FileDisk extends Model
if ($limit == 'all') {
return collect(['data' => $query->get()]);
}
return $query->paginate($limit);
}
@ -89,18 +89,17 @@ class FileDisk extends Model
{
$prefix = env('DYNAMIC_DISK_PREFIX', 'temp_');
config(['filesystems.default' => $prefix . $driver]);
config(['filesystems.default' => $prefix.$driver]);
$disks = config('filesystems.disks.' . $driver);
$disks = config('filesystems.disks.'.$driver);
foreach ($disks as $key => $value) {
if ($credentials->has($key)) {
$disks[$key] = $credentials[$key];
}
}
config(['filesystems.disks.' . $prefix . $driver => $disks]);
config(['filesystems.disks.'.$prefix.$driver => $disks]);
}
public static function validateCredentials($credentials, $disk)
@ -113,16 +112,16 @@ class FileDisk extends Model
try {
$root = '';
if($disk == 'dropbox'){
if ($disk == 'dropbox') {
$root = $credentials['root'].'/';
}
\Storage::disk($prefix . $disk)->put($root.'crater_temp.text', 'Check Credentials');
\Storage::disk($prefix.$disk)->put($root.'crater_temp.text', 'Check Credentials');
if(\Storage::disk($prefix . $disk)->exists($root.'crater_temp.text')) {
if (\Storage::disk($prefix.$disk)->exists($root.'crater_temp.text')) {
$exists = true;
\Storage::disk($prefix . $disk)->delete($root.'crater_temp.text');
\Storage::disk($prefix.$disk)->delete($root.'crater_temp.text');
}
} catch(\Exception $e) {
} catch (\Exception $e) {
$exists = false;
}
@ -165,7 +164,7 @@ class FileDisk extends Model
'driver' => $request->driver,
];
if(!$this->setAsDefault()) {
if (! $this->setAsDefault()) {
if ($request->set_as_default) {
self::updateDefaultDisks();
}