1 | <?php |
||
16 | final class Converter implements ConverterInterface |
||
17 | { |
||
18 | /** |
||
19 | * The key to search for in the INI file to find the browscap settings |
||
20 | */ |
||
21 | private const BROWSCAP_VERSION_KEY = 'GJK_Browscap_Version'; |
||
22 | |||
23 | /** |
||
24 | * @var \Psr\Log\LoggerInterface |
||
25 | */ |
||
26 | private $logger; |
||
27 | |||
28 | /** |
||
29 | * The cache instance |
||
30 | * |
||
31 | * @var \BrowscapPHP\Cache\BrowscapCacheInterface |
||
32 | */ |
||
33 | private $cache; |
||
34 | |||
35 | /** |
||
36 | * a filesystem patternHelper instance |
||
37 | * |
||
38 | * @var Filesystem |
||
39 | */ |
||
40 | private $filessystem; |
||
41 | |||
42 | /** |
||
43 | * version of the ini file |
||
44 | * |
||
45 | * @var int |
||
46 | */ |
||
47 | private $iniVersion = 0; |
||
48 | |||
49 | /** |
||
50 | * Converter constructor. |
||
51 | * |
||
52 | * @param LoggerInterface $logger |
||
53 | * @param BrowscapCacheInterface $cache |
||
54 | 6 | */ |
|
55 | public function __construct(LoggerInterface $logger, BrowscapCacheInterface $cache) |
||
61 | |||
62 | /** |
||
63 | * Sets a filesystem instance |
||
64 | * |
||
65 | * @param Filesystem $file |
||
66 | 6 | */ |
|
67 | public function setFilesystem(Filesystem $file) : void |
||
71 | |||
72 | /** |
||
73 | * converts a file |
||
74 | * |
||
75 | * @param string $iniFile |
||
76 | * |
||
77 | * @throws FileNotFoundException |
||
78 | 2 | * @throws ErrorReadingFileException |
|
79 | */ |
||
80 | 2 | public function convertFile(string $iniFile) : void |
|
98 | 2 | ||
99 | /** |
||
100 | 2 | * converts the string content |
|
101 | * |
||
102 | 2 | * @param string $iniString |
|
103 | */ |
||
104 | 2 | public function convertString(string $iniString) : void |
|
160 | 1 | ||
161 | 1 | /** |
|
162 | * Parses the ini data to get the version of loaded ini file |
||
163 | 1 | * |
|
164 | 1 | * @param string $iniString The loaded ini data |
|
165 | 1 | * |
|
166 | * @return int |
||
167 | */ |
||
168 | public function getIniVersion(string $iniString) : int |
||
181 | |||
182 | /** |
||
183 | * sets the version |
||
184 | * |
||
185 | * @param int $version |
||
186 | */ |
||
187 | public function setVersion(int $version) : void |
||
191 | |||
192 | /** |
||
193 | * stores the version of the ini file into cache |
||
194 | */ |
||
195 | public function storeVersion() : void |
||
203 | 2 | ||
204 | 2 | /** |
|
205 | 2 | * Parses the ini data to get the releaseDate of loaded ini file |
|
206 | * |
||
207 | * @param string $iniString The loaded ini data |
||
208 | * |
||
209 | * @return string|null |
||
210 | */ |
||
211 | private function getIniReleaseDate(string $iniString) : ?string |
||
221 | 2 | ||
222 | 2 | /** |
|
223 | 2 | * Parses the ini data to get the releaseDate of loaded ini file |
|
224 | * |
||
225 | * @param string $iniString The loaded ini data |
||
226 | * |
||
227 | * @return string|null |
||
228 | */ |
||
229 | private function getIniType(string $iniString) : ?string |
||
239 | } |
||
240 |