-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSubscriptionProviders.php
More file actions
41 lines (36 loc) · 1.84 KB
/
Copy pathSubscriptionProviders.php
File metadata and controls
41 lines (36 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
require_once 'Subscriptions.php';
abstract class SubscriptionProvider {
abstract protected function createSubscription(string $type): Subscription;
public function processOrder(string $type): Subscription {
return $this->createSubscription(strtolower($type));
}
}
class WebSite extends SubscriptionProvider {
protected function createSubscription(string $type): Subscription {
return match ($type) {
'domestic' => new DomesticSubscription(150, 1, ['1+1', 'ICTV'], ['Базовий плеєр']),
'educational' => new EducationalSubscription(100, 3, ['Discovery'], ['Лекції']),
'premium' => new PremiumSubscription(300, 12, ['Усі HD', 'HBO'], ['4K', 'Без реклами']),
default => throw new Exception("Тип не підтримується сайтом")
};
}
}
class MobileApp extends SubscriptionProvider {
protected function createSubscription(string $type): Subscription {
return match ($type) {
'domestic' => new DomesticSubscription(140, 1, ['1+1'], ['Мобільний кеш']),
'premium' => new PremiumSubscription(280, 6, ['Усі HD'], ['Фоновий режим']),
default => throw new Exception("Тип не підтримується додатком")
};
}
}
class ManagerCall extends SubscriptionProvider {
protected function createSubscription(string $type): Subscription {
return match ($type) {
'educational' => new EducationalSubscription(110, 6, ['Discovery'], ['Куратор']),
'premium' => new PremiumSubscription(350, 24, ['Усі UltraHD'], ['VIP підтримка 24/7']),
default => throw new Exception("Менеджер не може оформити цей тип")
};
}
}