diff --git a/src/AdministrationUnit/Response/AdministrationUnit.php b/src/AdministrationUnit/Response/AdministrationUnit.php index 3c57595..d70bf63 100644 --- a/src/AdministrationUnit/Response/AdministrationUnit.php +++ b/src/AdministrationUnit/Response/AdministrationUnit.php @@ -4,6 +4,7 @@ use HnutiBrontosaurus\BisClient\AdministrationUnit\Category; use HnutiBrontosaurus\BisClient\Response\Coordinates; +use function str_starts_with; final class AdministrationUnit @@ -73,7 +74,7 @@ public static function fromResponseData(array $data): self : null, $data['phone'] !== '' ? $data['phone'] : null, $data['email'] !== '' ? $data['email'] : null, - $data['www'] !== '' ? $data['www'] : null, + $data['www'] !== '' ? self::fixUrl($data['www']) : null, Category::fromScalar($data['category']['slug']), $data['chairman'] !== null ? $data['chairman']['name'] : null, $data['manager'] !== null ? $data['manager']['name'] : null, @@ -81,6 +82,15 @@ public static function fromResponseData(array $data): self ); } + private static function fixUrl(string $url): string + { + if (str_starts_with($url, 'http')) { + return $url; + } + + return 'http://' . $url; + } + public function getId(): int {