1 | <?php |
||
12 | final class Security implements Common |
||
13 | { |
||
14 | /** |
||
15 | * Токен для тестового доступа |
||
16 | */ |
||
17 | const TEST_TOKEN = '7c0c2193d27108a509abd8ea84a8750c82b3a520'; |
||
18 | |||
19 | /** |
||
20 | * Домен продакшен сервера API |
||
21 | */ |
||
22 | const PROD_API_HOST = 'https://openapi.e.lanbook.com'; |
||
23 | |||
24 | /** |
||
25 | * Домен тестового сервера API |
||
26 | */ |
||
27 | const TEST_API_HOST = 'http://openapi.landev.ru'; |
||
28 | |||
29 | /** |
||
30 | * Домен дев сервера API |
||
31 | */ |
||
32 | const DEV_API_HOST = 'http://eop.local'; |
||
33 | |||
34 | /** |
||
35 | * Домен продакшен сервера ЭБС |
||
36 | */ |
||
37 | const PROD_EBS_HOST = 'https://e.lanbook.com'; |
||
38 | |||
39 | /** |
||
40 | * Домен тестового сервера ЭБС |
||
41 | */ |
||
42 | const TEST_EBS_HOST = 'http://ebs.landev.ru'; |
||
43 | |||
44 | /** |
||
45 | * Домен дев сервера ЭБС |
||
46 | */ |
||
47 | const DEV_EBS_HOST = 'http://ebs.local'; |
||
48 | |||
49 | /** |
||
50 | * Инстанс клиента API |
||
51 | * |
||
52 | * @var Client |
||
53 | */ |
||
54 | private $client; |
||
55 | |||
56 | /** |
||
57 | * Конструктор |
||
58 | * |
||
59 | * @param Client $client Истанс клиента |
||
60 | * @throws Exception |
||
61 | */ |
||
62 | 2 | public function __construct(Client $client) |
|
70 | |||
71 | 6 | public static function getApiHost() |
|
75 | |||
76 | public static function getEbsHost() |
||
80 | |||
81 | /** |
||
82 | * @param $type |
||
83 | * @param $id |
||
84 | * @return mixed |
||
85 | * @throws Exception |
||
86 | */ |
||
87 | 1 | public function getDemoUrl($type, $id) |
|
91 | |||
92 | /** |
||
93 | * Получение данных для запроса через API |
||
94 | * |
||
95 | * @param string $method Http-метод запроса |
||
96 | * @param array $params Параметры для формирования урла |
||
97 | * |
||
98 | * @return array |
||
99 | * |
||
100 | * @throws Exception |
||
101 | */ |
||
102 | 2 | public function getUrl($method, array $params = []) |
|
121 | |||
122 | /** |
||
123 | * @param $uid |
||
124 | * @param null $fio |
||
125 | * @param null $email |
||
126 | * @param null $redirect |
||
127 | * @return mixed |
||
128 | * @throws Exception |
||
129 | */ |
||
130 | 1 | public function getAutologinUrl($uid, $fio = null, $email = null, $redirect = null) |
|
143 | } |
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: