-
Notifications
You must be signed in to change notification settings - Fork 0
/
CoR.php
69 lines (60 loc) · 2.29 KB
/
CoR.php
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
/**
* @author Artemii Karkusha
* @copyright Copyright (c) (https://www.linkedin.com/in/artemiy-karkusha/)
*/
declare(strict_types=1);
namespace ArtemiiKarkusha\DesignPatterns\Controller\Test;
use Magento\Framework\App\Action\HttpGetActionInterface;
use Magento\Framework\Controller\ResultFactory;
use ArtemiiKarkusha\DesignPatterns\Api\CoR\Service\EmergencyServicesManagerInterface;
use ArtemiiKarkusha\DesignPatterns\Api\CoR\Model\PhoneInterfaceFactory;
use ArtemiiKarkusha\DesignPatterns\Api\CoR\Model\PhoneInterface;
use ArtemiiKarkusha\DesignPatterns\Service\CoR\FireDepartmentCallerService;
use ArtemiiKarkusha\DesignPatterns\Service\CoR\MedicalServiceCaller;
use ArtemiiKarkusha\DesignPatterns\Service\CoR\PoliceDepartmentCallerService;
use Magento\Framework\Controller\ResultInterface;
class CoR implements HttpGetActionInterface
{
public const SERVICE_PHONE_NUMBER_WHICH_NOT_EXIST = '248';
/**
* @param ResultFactory $resultFactory
* @param EmergencyServicesManagerInterface $emergencyServicesManager
* @param PhoneInterfaceFactory $phoneInterfaceFactory
*/
public function __construct(
private ResultFactory $resultFactory,
private EmergencyServicesManagerInterface $emergencyServicesManager,
private PhoneInterfaceFactory $phoneInterfaceFactory
) {
}
/**
* @inheritDoc
*/
public function execute(): ResultInterface
{
return $this->resultFactory->create(ResultFactory::TYPE_RAW)
->setContents($this->getContents());
}
/**
* @return string
*/
public function getContents(): string
{
/** @var PhoneInterface $phone */
$phone = $this->phoneInterfaceFactory->create();
$this->emergencyServicesManager->call(
$phone->setNumber(FireDepartmentCallerService::EMERGENCY_SERVICE_PHONE_NUMBER)
);
$this->emergencyServicesManager->call(
$phone->setNumber(MedicalServiceCaller::EMERGENCY_SERVICE_PHONE_NUMBER)
);
$this->emergencyServicesManager->call(
$phone->setNumber(PoliceDepartmentCallerService::EMERGENCY_SERVICE_PHONE_NUMBER)
);
$this->emergencyServicesManager->call(
$phone->setNumber(self::SERVICE_PHONE_NUMBER_WHICH_NOT_EXIST)
);
return '';
}
}