1 | <?php |
||
18 | final class Security implements Common |
||
19 | { |
||
20 | /** |
||
21 | * Токен для тестового доступа |
||
22 | */ |
||
23 | const TEST_TOKEN = '7c0c2193d27108a509abd8ea84a8750c82b3a520'; |
||
24 | |||
25 | /** |
||
26 | * Домен продакшен сервера API |
||
27 | */ |
||
28 | const PROD_API_HOST = 'https://openapi.e.lanbook.com'; |
||
29 | |||
30 | /** |
||
31 | * Домен тестового сервера API |
||
32 | */ |
||
33 | const TEST_API_HOST = 'http://openapi.landev.ru'; |
||
34 | |||
35 | /** |
||
36 | * Домен дев сервера API |
||
37 | */ |
||
38 | const DEV_API_HOST = 'http://eop.local'; |
||
39 | |||
40 | /** |
||
41 | * Домен продакшен сервера ЭБС |
||
42 | */ |
||
43 | const PROD_EBS_HOST = 'https://e.lanbook.com'; |
||
44 | |||
45 | /** |
||
46 | * Домен тестового сервера ЭБС |
||
47 | */ |
||
48 | const TEST_EBS_HOST = 'http://ebs.landev.ru'; |
||
49 | |||
50 | /** |
||
51 | * Домен дев сервера ЭБС |
||
52 | */ |
||
53 | const DEV_EBS_HOST = 'http://ebs.local'; |
||
54 | |||
55 | /** |
||
56 | * Инстанс клиента API |
||
57 | * |
||
58 | * @var Client |
||
59 | */ |
||
60 | private $client; |
||
61 | |||
62 | /** |
||
63 | * Конструктор |
||
64 | * |
||
65 | * @param Client $client Истанс клиента |
||
66 | * @throws Exception |
||
67 | */ |
||
68 | 2 | public function __construct(Client $client) |
|
76 | |||
77 | /** |
||
78 | * Получение данных для запроса через API |
||
79 | * |
||
80 | * @param string $method Http-метод запроса |
||
81 | * @param array $params Параметры для формирования урла |
||
82 | * |
||
83 | * @return array |
||
84 | * |
||
85 | * @throws Exception |
||
86 | */ |
||
87 | 2 | public function getUrl($method, array $params = []) |
|
106 | |||
107 | /** |
||
108 | * @param $type |
||
109 | * @param $id |
||
110 | * @return mixed |
||
111 | * @throws Exception |
||
112 | */ |
||
113 | 1 | public function getDemoUrl($type, $id) |
|
117 | |||
118 | /** |
||
119 | * @param $uid |
||
120 | * @param null $fio |
||
121 | * @param null $email |
||
122 | * @param null $redirect |
||
123 | * @return mixed |
||
124 | * @throws Exception |
||
125 | */ |
||
126 | 1 | public function getAutologinUrl($uid, $fio = null, $email = null, $redirect = null) { |
|
138 | |||
139 | 13 | public static function getApiHost() |
|
143 | |||
144 | public static function getEbsHost() |
||
148 | } |
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: