mirror of
https://github.com/tiennm99/coolify.git
synced 2026-10-05 06:13:42 +00:00
refactor(scheduled-task): simplify server() with nullsafe operators and add return type
Replace nested null checks with nullsafe operator chains, add ?Server return type, drop unreachable database branch, and cover all paths with feature tests.
This commit is contained in:
1 parent
8e22ce4ba7
commit
1849b5903e
2 files changed
+72
-12
No files matched your search
@@ -76,20 +76,14 @@ class ScheduledTask extends BaseModel
|
||||
return $this->hasMany(ScheduledTaskExecution::class)->orderBy('created_at', 'desc');
|
||||
}
|
||||
|
||||
public function server()
|
||||
public function server(): ?Server
|
||||
{
|
||||
if ($this->application) {
|
||||
if ($this->application->destination && $this->application->destination->server) {
|
||||
return $this->application->destination->server;
|
||||
}
|
||||
} elseif ($this->service) {
|
||||
if ($this->service->destination && $this->service->destination->server) {
|
||||
return $this->service->destination->server;
|
||||
}
|
||||
} elseif ($this->database) {
|
||||
if ($this->database->destination && $this->database->destination->server) {
|
||||
return $this->database->destination->server;
|
||||
}
|
||||
return $this->application->destination?->server;
|
||||
}
|
||||
|
||||
if ($this->service) {
|
||||
return $this->service->destination?->server;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
Reference in new issue
Block a user