Skip to content

Commit

Permalink
fix: TypeError: trim(): Argument #1 ($string) must be of type string,…
Browse files Browse the repository at this point in the history
… null given
  • Loading branch information
chaz6chez committed Sep 24, 2024
1 parent 794e7c8 commit 188296d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Traits/RegistrarMethods.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ trait RegistrarMethods
{
protected ?int $registrarTimerId = null;

protected ?string $registrarHostIp = null;

protected ?int $registrarHostPort = null;

/**
* @return RegistrarInterface|null
*/
Expand Down Expand Up @@ -79,7 +83,7 @@ public function registrarStop(Worker $worker): void
*/
public function registrarGetHostIp(): string
{
return trim(shell_exec('curl -s ifconfig.me'));
return $this->registrarHostIp ?: ($this->registrarHostIp = trim(shell_exec('curl -s ifconfig.me')));
}

/**
Expand All @@ -88,7 +92,7 @@ public function registrarGetHostIp(): string
public function registrarGetHostPort(): ?int
{
$serverName = static::getServerName();
return config("plugin.workbunny.webman-push-server.app.$serverName.port");
return $this->registrarHostPort ?: ($this->registrarHostPort = config("plugin.workbunny.webman-push-server.app.$serverName.port"));
}

/**
Expand Down

0 comments on commit 188296d

Please sign in to comment.