Advertisement
Guest User

Untitled

a guest
Jun 29th, 2021
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.71 KB | None | 0 0
  1. <?php
  2. class BillingServiceFactory
  3. {
  4.     public static function create(User $user): BillingService
  5.     {
  6.         if ($user->isDemo()) {
  7.             return new DemoBillingService();
  8.         } elseif ($user->hasParam1()) {
  9.             return new Api1BillingService($apiV1Url, $apiV1Key);
  10.         } elseif ($user->hasParam2()) {
  11.             return new Api2BillingService($apiV2Url, $apiV1Key);
  12.         } elseif ($user->hasParam3()) {
  13.             return new Api3BillingService($apiV3Url, $apiV1Key);
  14.         }
  15.         return null;
  16.     }
  17. }
  18.  
  19. class Api1BillingService {
  20.    public function __construct(string $url, string $privateKey) {
  21.         $this->url = $url;
  22.         $this->privateKey = $privateKey;
  23.    }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement