add null check for platform

This commit is contained in:
Chirag Aggarwal 2025-07-03 16:26:56 +05:30
parent 2d00052db6
commit f62c3135df
2 changed files with 4 additions and 4 deletions

View file

@ -50,10 +50,10 @@ class Platform
/**
* Get user-friendly platform name from a scheme.
*
* @param string $scheme
* @param string|null $scheme
* @return string Empty string if scheme is not found.
*/
public static function getNameByScheme(string $scheme): string
public static function getNameByScheme(?string $scheme): string
{
return self::$names[$scheme] ?? '';
}
@ -62,7 +62,7 @@ class Platform
{
$hostnames = [];
foreach ($platforms as $platform) {
$type = $platform['type'] ?? self::TYPE_UNKNOWN;
$type = strtolower($platform['type'] ?? self::TYPE_UNKNOWN);
$hostname = strtolower($platform['hostname'] ?? '');
$key = strtolower($platform['key'] ?? '');

View file

@ -12,7 +12,7 @@ class Redirect extends Origin
*/
public function getDescription(): string
{
$platform = $this->scheme ? Platform::getNameByScheme($this->scheme) : null;
$platform = Platform::getNameByScheme($this->scheme);
$host = $this->host ? '(' . $this->host . ')' : '';
if (empty($this->host) && empty($this->scheme)) {