1 | <?php |
||
20 | abstract class DownloadAbstract |
||
21 | { |
||
22 | /** |
||
23 | * The format for the user agent to set for all requests made by the class |
||
24 | */ |
||
25 | const USER_AGENT_FORMAT = '%libName %libVersion (%client)'; |
||
26 | |||
27 | /** |
||
28 | * The URI to get the current Browscap data (in the configured format) |
||
29 | * |
||
30 | * @var string |
||
31 | */ |
||
32 | protected $sourceUri; |
||
33 | |||
34 | /** |
||
35 | * @var Client |
||
36 | */ |
||
37 | protected $client; |
||
38 | |||
39 | /** |
||
40 | * Download constructor. |
||
41 | * |
||
42 | * @param string $sourceUri |
||
43 | * @param array $clientOptions |
||
44 | * |
||
45 | * @throws SourceConditionNotSatisfiedException |
||
46 | */ |
||
47 | public function __construct(string $sourceUri, array $clientOptions = []) |
||
58 | |||
59 | /** |
||
60 | * @return Client |
||
61 | */ |
||
62 | public function getClient() : Client |
||
66 | |||
67 | /** |
||
68 | * @param Client $client |
||
69 | */ |
||
70 | protected function setClient(Client $client) |
||
74 | |||
75 | /** |
||
76 | * @return string |
||
77 | */ |
||
78 | public function getSourceUri() : string |
||
82 | |||
83 | /** |
||
84 | * @param string $sourceUri |
||
85 | * |
||
86 | * @return DownloadAbstract |
||
87 | */ |
||
88 | protected function setSourceUri(string $sourceUri) : DownloadAbstract |
||
94 | |||
95 | /** |
||
96 | * @return string |
||
97 | */ |
||
98 | protected function getUserAgent() |
||
106 | |||
107 | /** |
||
108 | * @inheritdoc |
||
109 | * |
||
110 | * @throws SourceUnavailableException |
||
111 | * @throws \RuntimeException |
||
112 | */ |
||
113 | public function getContent() : \Generator |
||
125 | |||
126 | /** |
||
127 | * @param $uri |
||
128 | * |
||
129 | * @return StreamInterface |
||
130 | * @throws SourceUnavailableException |
||
131 | */ |
||
132 | protected function loadContent($uri) : StreamInterface |
||
152 | } |
||
153 |