Skip to content

Commit 94ba4af

Browse files
author
guuske
committed
Merge remote-tracking branch 'origin/master'
2 parents 6c34079 + dd243e2 commit 94ba4af

File tree

2 files changed

+24
-21
lines changed

2 files changed

+24
-21
lines changed

src/Console/RebuildRaidArray.php

+17-14
Original file line numberDiff line numberDiff line change
@@ -11,36 +11,39 @@ class RebuildRaidArray extends Command
1111
//region Public Access
1212

1313
/**
14-
* Rebuild the RAID array underlying the given Storage disk name
14+
* Rebuild the RAID array underlying the given Storage disk name.
1515
*/
1616
public function handle()
1717
{
1818
$disk = $this->argument('disk');
19-
if (!$disk) {
20-
$this->error('Please provide the disk you want the RAID ' .
19+
if (! $disk) {
20+
$this->error('Please provide the disk you want the RAID '.
2121
'configuration to be rebuilt for.');
22+
2223
return;
2324
}
2425

25-
$diskConfig = config('filesystems.disks.' . $disk);
26-
if (!$diskConfig) {
27-
$this->error('Cannot find the filesystem configuration for disk "' .
28-
$disk . '".');
26+
$diskConfig = config('filesystems.disks.'.$disk);
27+
if (! $diskConfig) {
28+
$this->error('Cannot find the filesystem configuration for disk "'.
29+
$disk.'".');
30+
2931
return;
3032
}
3133

3234
$fileSystems = [];
33-
if(!isset($diskConfig['disks'])) {
34-
$this->error('Please make sure you have a key "disks" in the ' .
35-
'configuration of the disk "' . $disk . '".');
35+
if (! isset($diskConfig['disks'])) {
36+
$this->error('Please make sure you have a key "disks" in the '.
37+
'configuration of the disk "'.$disk.'".');
38+
3639
return;
3740
}
38-
foreach($diskConfig['disks'] as $diskName) {
41+
foreach ($diskConfig['disks'] as $diskName) {
3942
$fileSystems[] = Storage::disk($diskName);
4043
}
4144

4245
$raidLevel = $diskConfig['raidLevel'] ?? 1;
43-
if($raidLevel == 1) {
46+
if ($raidLevel == 1) {
4447
$adapter = new RaidOneAdapter($fileSystems);
4548
$adapter->rebuildArray();
4649
}
@@ -62,8 +65,8 @@ public function handle()
6265
*
6366
* @var string
6467
*/
65-
protected $signature = 'raid:rebuild-array {disk : The configured disk ' .
68+
protected $signature = 'raid:rebuild-array {disk : The configured disk '.
6669
'for which to rebuild the array}';
6770

6871
//endregion
69-
}
72+
}

src/ServiceProvider.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,31 @@
55
use League\Flysystem\Filesystem;
66
use Illuminate\Support\Facades\Storage;
77
use PHPGuus\FlysystemRaid\RaidOneAdapter;
8-
use Illuminate\Support\ServiceProvider as IlluminateServiceProvider;
98
use PHPGuus\RaidStorage\Console\RebuildRaidArray;
9+
use Illuminate\Support\ServiceProvider as IlluminateServiceProvider;
1010

1111
class ServiceProvider extends IlluminateServiceProvider
1212
{
1313
public function boot()
1414
{
15-
Storage::extend('raid', function($app, $config) {
15+
Storage::extend('raid', function ($app, $config) {
1616
$fileSystems = [];
17-
foreach($config['disks'] as $diskName) {
17+
foreach ($config['disks'] as $diskName) {
1818
$fileSystems[] = Storage::disk($diskName);
1919
}
2020
$raidLevel = $config['raidLevel'] ?? 1;
2121

22-
if($raidLevel == 1) {
22+
if ($raidLevel == 1) {
2323
$adapter = new RaidOneAdapter($fileSystems);
2424
}
2525

2626
return new Filesystem($adapter);
2727
});
2828

2929
if ($this->app->runningInConsole()) {
30-
$this->commands([
31-
RebuildRaidArray::class
30+
$this->commands([
31+
RebuildRaidArray::class,
3232
]);
3333
}
3434
}
35-
}
35+
}

0 commit comments

Comments
 (0)