Skip to content

Commit fc52548

Browse files
committed
Make code look prettier
1 parent 8b403aa commit fc52548

4 files changed

+16
-36
lines changed

src/CommandGenerator.php

+10-21
Original file line numberDiff line numberDiff line change
@@ -60,21 +60,18 @@ public function run(): Collection
6060

6161
public function commandsArray(): Collection
6262
{
63-
return collect($this->recipe)->map(function ($path, $key) {
64-
return [
65-
'origin' => ($this->operation === 'pull') ? $this->remotePath($key) : $this->localPath($key),
66-
'target' => ($this->operation === 'pull') ? $this->localPath($key) : $this->remotePath($key),
67-
'options' => $this->options,
68-
'port' => $this->port(),
69-
];
70-
});
63+
return collect($this->recipe)->map(fn ($path, $key) => [
64+
'origin' => ($this->operation === 'pull') ? $this->remotePath($key) : $this->localPath($key),
65+
'target' => ($this->operation === 'pull') ? $this->localPath($key) : $this->remotePath($key),
66+
'options' => $this->options,
67+
'port' => $this->port(),
68+
]);
7169
}
7270

7371
public function commandsString(): Collection
7472
{
75-
return $this->commandsArray()->map(function ($command) {
76-
return "rsync -e 'ssh -p {$command['port']}' {$command['options']} {$command['origin']} {$command['target']}";
77-
});
73+
return $this->commandsArray()
74+
->map(fn ($command) => "rsync -e 'ssh -p {$command['port']}' {$command['options']} {$command['origin']} {$command['target']}");
7875
}
7976

8077
protected function port(): string
@@ -94,19 +91,11 @@ protected function remotePath(string $key): string
9491

9592
protected function localPathEqualsRemotePath(): bool
9693
{
97-
if ($this->localPath(0) !== $this->remotePath(0)) {
98-
return false;
99-
}
100-
101-
return true;
94+
return $this->localPath(0) === $this->remotePath(0);
10295
}
10396

10497
protected function remoteIsReadOnly(): bool
10598
{
106-
if (! Arr::get($this->remote, 'read_only', false)) {
107-
return false;
108-
}
109-
110-
return true;
99+
return Arr::get($this->remote, 'read_only', false);
111100
}
112101
}

src/PathGenerator.php

+3-7
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,13 @@ protected function joinPaths(): string
3232
}
3333
}
3434

35-
return preg_replace('#/+#', '/', join('/', $paths));
35+
return preg_replace('#/+#', '/', implode('/', $paths));
3636
}
3737

3838
protected function remoteHostEqualsLocalHost(string $remoteHost): bool
3939
{
40-
$ip = Http::get('https://api.ipify.org/?format=json')->json('ip');
40+
$publicIp = Http::get('https://api.ipify.org/?format=json')->json('ip');
4141

42-
if ($ip !== $remoteHost) {
43-
return false;
44-
}
45-
46-
return true;
42+
return $publicIp === $remoteHost;
4743
}
4844
}

src/SyncProcessor.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88

99
class SyncProcessor
1010
{
11-
protected $commands;
11+
protected Collection $commands;
1212

13-
protected $artisanCommand;
13+
protected Command $artisanCommand;
1414

1515
public function commands(Collection $commands): self
1616
{

src/SyncServiceProvider.php

+1-6
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
class SyncServiceProvider extends ServiceProvider
88
{
9-
public function boot()
9+
public function boot(): void
1010
{
1111
$this->commands([
1212
Commands\Sync::class,
@@ -20,9 +20,4 @@ public function boot()
2020

2121
$this->mergeConfigFrom(__DIR__.'/../config/sync.php', 'sync');
2222
}
23-
24-
public function register()
25-
{
26-
//
27-
}
2823
}

0 commit comments

Comments
 (0)