printu/customerio

View on GitHub
src/Region.php

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
<?php

declare(strict_types=1);

namespace Customerio;

use Customerio\Region\InvalidRegionException;
use Customerio\Region\RegionInterface;
use Customerio\Region\RegionEu;
use Customerio\Region\RegionUs;

class Region
{
    public static function factory(string $region = 'us'): RegionInterface
    {
        switch ($region) {
            case 'us':
                return new RegionUs();
            case 'eu':
                return new RegionEu();
            default:
                throw new InvalidRegionException("Unknown region: {$region}");
        }
    }
}