misuzu/src/Net/IPAddress.php

20 lines
555 B
PHP
Raw Normal View History

2022-09-13 13:14:49 +00:00
<?php
namespace Misuzu\Net;
use Misuzu\MisuzuContext;
2023-01-05 20:03:26 +00:00
// remains for now for backwards compatibility with existing ::create methods
// plan is for those ::create methods to Fucking Die so that's fine for now
2022-09-13 13:14:49 +00:00
final class IPAddress {
private static MisuzuContext $context;
2022-09-13 13:14:49 +00:00
public static function init(MisuzuContext $ctx): void {
2023-01-05 20:03:26 +00:00
self::$context = $ctx;
}
public static function country(string $address, string $fallback = 'XX'): string {
return self::$context->getGeoIP()->getIsoCountryCode($address, $fallback);
2022-09-13 13:14:49 +00:00
}
}