Total Complexity | 3 |
Total Lines | 35 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
17 | class ApiFactory implements ApiFactoryInterface |
||
18 | { |
||
19 | /** |
||
20 | * @var AuthHandlerCollectionInterface |
||
21 | */ |
||
22 | private $handlers; |
||
23 | |||
24 | public function __construct(AuthHandlerCollectionInterface $handlers = null) |
||
25 | { |
||
26 | $this->handlers = $handlers ?? new AuthHandlerCollection([ |
||
27 | new ClientAuthHandler(), |
||
28 | new BotAuthHandler(), |
||
29 | ]); |
||
30 | } |
||
31 | |||
32 | /** |
||
33 | * {@inheritdoc} |
||
34 | */ |
||
35 | public function create( |
||
36 | ConfigInterface $config, |
||
37 | ApiConstructorInterface $apiConstructor |
||
38 | ): API { |
||
39 | $api = $apiConstructor->create(); |
||
40 | $api->session = $config->getSessionPath(); |
||
41 | $this->auth($config, $api->API); |
||
42 | |||
43 | return $api; |
||
44 | } |
||
45 | |||
46 | /** |
||
47 | * @throws AuthHandlerException |
||
48 | */ |
||
49 | private function auth(ConfigInterface $config, MTProto $proto): void |
||
52 | } |
||
53 | } |
||
54 |