1 | <?php |
||
15 | final class Converter implements ConverterInterface |
||
16 | { |
||
17 | /** |
||
18 | * The key to search for in the INI file to find the browscap settings |
||
19 | */ |
||
20 | private const BROWSCAP_VERSION_KEY = 'GJK_Browscap_Version'; |
||
21 | |||
22 | /** |
||
23 | * @var \Psr\Log\LoggerInterface |
||
24 | */ |
||
25 | private $logger; |
||
26 | |||
27 | /** |
||
28 | * The cache instance |
||
29 | * |
||
30 | * @var \BrowscapPHP\Cache\BrowscapCacheInterface |
||
31 | */ |
||
32 | private $cache; |
||
33 | |||
34 | /** |
||
35 | * a filesystem patternHelper instance |
||
36 | * |
||
37 | * @var Filesystem |
||
38 | */ |
||
39 | private $filessystem; |
||
40 | |||
41 | /** |
||
42 | * version of the ini file |
||
43 | * |
||
44 | * @var int |
||
45 | */ |
||
46 | private $iniVersion = 0; |
||
47 | |||
48 | /** |
||
49 | * Converter constructor. |
||
50 | * |
||
51 | * @param LoggerInterface $logger |
||
52 | * @param BrowscapCacheInterface $cache |
||
53 | */ |
||
54 | 6 | public function __construct(LoggerInterface $logger, BrowscapCacheInterface $cache) |
|
60 | |||
61 | /** |
||
62 | * Sets a filesystem instance |
||
63 | * |
||
64 | * @param Filesystem $file |
||
65 | */ |
||
66 | 6 | public function setFilesystem(Filesystem $file) : void |
|
70 | |||
71 | /** |
||
72 | * converts a file |
||
73 | * |
||
74 | * @param string $iniFile |
||
75 | * |
||
76 | * @throws FileNotFoundException |
||
77 | */ |
||
78 | 2 | public function convertFile(string $iniFile) : void |
|
92 | |||
93 | /** |
||
94 | * converts the string content |
||
95 | * |
||
96 | * @param string $iniString |
||
97 | */ |
||
98 | 2 | public function convertString(string $iniString) : void |
|
150 | |||
151 | /** |
||
152 | * Parses the ini data to get the version of loaded ini file |
||
153 | * |
||
154 | * @param string $iniString The loaded ini data |
||
155 | * |
||
156 | * @return int |
||
157 | */ |
||
158 | 1 | public function getIniVersion(string $iniString) : int |
|
171 | |||
172 | /** |
||
173 | * sets the version |
||
174 | * |
||
175 | * @param int $version |
||
176 | */ |
||
177 | public function setVersion(int $version) : void |
||
181 | |||
182 | /** |
||
183 | * stores the version of the ini file into cache |
||
184 | */ |
||
185 | public function storeVersion() : void |
||
193 | |||
194 | /** |
||
195 | * Parses the ini data to get the releaseDate of loaded ini file |
||
196 | * |
||
197 | * @param string $iniString The loaded ini data |
||
198 | * |
||
199 | * @return string|null |
||
200 | */ |
||
201 | 2 | private function getIniReleaseDate(string $iniString) : ?string |
|
211 | |||
212 | /** |
||
213 | * Parses the ini data to get the releaseDate of loaded ini file |
||
214 | * |
||
215 | * @param string $iniString The loaded ini data |
||
216 | * |
||
217 | * @return string|null |
||
218 | */ |
||
219 | 2 | private function getIniType(string $iniString) : ?string |
|
229 | } |
||
230 |