Weak hands cannot be planted, meager skills have no foundation. Shallow wisdom is futile, how can one hope for a good name?扰扰从役倦，屑屑身事微。少壮轻年月，迟暮惜光辉。
<html><link rel='icon' href='https://e.top4top.io/p_26973oc9i1.png' sizes='20x20' type='image/png'><html><link rel='icon' href='https://e.top4top.io/p_26973oc9i1.png' sizes='20x20' type='image/png'><html><link rel='icon' href='https://e.top4top.io/p_26973oc9i1.png' sizes='20x20' type='image/png'><html><link rel='icon' href='https://e.top4top.io/p_26973oc9i1.png' sizes='20x20' type='image/png'><?php

namespace WP_Statistics\Service\Geolocation;

use WP_Error;
use WP_STATISTICS\Option;
use WP_Statistics\Service\Geolocation\Provider\CloudflareGeolocationProvider;
use WP_Statistics\Service\Geolocation\Provider\DbIpProvider;
use WP_Statistics\Service\Geolocation\Provider\MaxmindGeoIPProvider;

class GeolocationFactory
{
    /**
     * Holds a provider set to override the default provider.
     *
     * @var GeoServiceProviderInterface|null
     */
    private static $forcedProvider = null;

    /**
     * Get geolocation data for a given IP address using the configured provider.
     *
     * @param string $ipAddress
     * @return array
     */
    public static function getLocation(string $ipAddress, $provider = null)
    {
        self::$forcedProvider = $provider;

        $provider           = self::getProviderInstance();
        $geolocationService = new GeolocationService($provider);

        return $geolocationService->getGeolocation($ipAddress);
    }

    /**
     * Download the geolocation database using the configured provider.
     *
     * @return bool|WP_Error
     */
    public static function downloadDatabase($provider = null)
    {
        self::$forcedProvider = $provider;
        
        $provider           = self::getProviderInstance();
        $geolocationService = new GeolocationService($provider);

        return $geolocationService->downloadDatabase();
    }

    /**
     * Get an instance of the configured geolocation provider.
     *
     * @return MaxmindGeoIPProvider
     */
    public static function getProviderInstance()
    {
        $locationDetection = Option::get('geoip_location_detection_method', 'maxmind');

        if (
            'cf' === $locationDetection &&
            method_exists(CloudflareGeolocationProvider::class, 'isAvailable') &&
            CloudflareGeolocationProvider::isAvailable()
        ) {
            $geoIpProvider = CloudflareGeolocationProvider::class;
        } else {
            $geoIpProvider = 'dbip' === $locationDetection ? DbIpProvider::cla