1 | <?php |
||
32 | class UriLocator implements LocatorInterface |
||
33 | { |
||
34 | /** |
||
35 | * Logger as it is |
||
36 | * |
||
37 | * @var LoggerInterface |
||
38 | */ |
||
39 | private $logger; |
||
40 | |||
41 | /** |
||
42 | * Decodes a string into PHP data |
||
43 | * |
||
44 | * @var DecoderInterface |
||
45 | */ |
||
46 | private $contentsDecoder; |
||
47 | |||
48 | /** |
||
49 | * Saves a proxy list in the cache and invalidates it by demand |
||
50 | * |
||
51 | * @var CacherInterface|null |
||
52 | */ |
||
53 | private $proxyCacher; |
||
54 | |||
55 | /** |
||
56 | * Options for URI proxy locator |
||
57 | * |
||
58 | * Example: |
||
59 | * ``` |
||
60 | * [ |
||
61 | * 'uri' => 'https://proxy-provider.ltd/my_proxy_list', |
||
62 | * 'format' => 'json', |
||
63 | * 'decoder_context' => [] |
||
64 | * ] |
||
65 | * ``` |
||
66 | * |
||
67 | * @var array |
||
68 | */ |
||
69 | private $options; |
||
70 | |||
71 | /** |
||
72 | * UriLocator constructor. |
||
73 | * |
||
74 | * @param LoggerInterface $logger Logger as it is |
||
75 | * @param DecoderInterface $contentsDecoder Decodes a string into PHP data |
||
76 | * @param array $options Options for URI proxy locator |
||
77 | */ |
||
78 | public function __construct(LoggerInterface $logger, DecoderInterface $contentsDecoder, array $options) |
||
89 | |||
90 | /** |
||
91 | * {@inheritdoc} |
||
92 | * |
||
93 | * @throws BadProxyListUriException |
||
94 | */ |
||
95 | public function locate(): iterable |
||
131 | |||
132 | /** |
||
133 | * Sets a proxy list cacher |
||
134 | * |
||
135 | * @param CacherInterface $proxyCacher Saves a proxy list in the cache and invalidates it by demand |
||
136 | * |
||
137 | * @return void |
||
138 | */ |
||
139 | public function setCacher(CacherInterface $proxyCacher): void |
||
143 | |||
144 | /** |
||
145 | * Configures URI proxy locator options |
||
146 | * |
||
147 | * @param OptionsResolver $optionsResolver Validates options and merges them with default values |
||
148 | * |
||
149 | * @return void |
||
150 | */ |
||
151 | protected function configureOptions(OptionsResolver $optionsResolver): void |
||
165 | } |
||
166 |