Total Complexity | 5 |
Total Lines | 46 |
Duplicated Lines | 0 % |
Coverage | 86.36% |
Changes | 3 | ||
Bugs | 1 | Features | 0 |
1 | <?php |
||
8 | class Installer |
||
9 | { |
||
10 | |||
11 | /** |
||
12 | * postInstall |
||
13 | * |
||
14 | * provides access to the current Composer instance |
||
15 | * run any post install tasks here |
||
16 | */ |
||
17 | 1 | public static function postInstall() |
|
18 | { |
||
19 | 1 | echo "\n"; |
|
20 | 1 | $cityUpdateError = false; |
|
21 | 1 | $updater = new Updater(); |
|
22 | $updater |
||
23 | 1 | ->getFileManager() |
|
24 | 1 | ->getDownloader() |
|
25 | 1 | ->setAdapter(Downloader::ADAPTER_CURL) |
|
26 | 1 | ->displayProgress(true); |
|
27 | 1 | self::output('Update maxmind databases started'); |
|
28 | try { |
||
29 | 1 | self::output('Updating city'); |
|
30 | 1 | $updater->setAdapter(Updater::ADAPTER_CITY)->update(); |
|
31 | } catch (\Exception $e) { |
||
32 | $cityUpdateError = true; |
||
33 | self::output('Download from maxmind failed : ' . $e->getMessage()); |
||
34 | } |
||
35 | 1 | if (!$cityUpdateError) { |
|
36 | 1 | self::output('Updating country'); |
|
37 | 1 | $updater->setAdapter(Updater::ADAPTER_COUNTRY)->update(); |
|
38 | 1 | self::output('Updating asn'); |
|
39 | 1 | $updater->setAdapter(Updater::ADAPTER_ASN)->update(); |
|
40 | } |
||
41 | 1 | self::output('Update maxmind databases finished'); |
|
42 | } |
||
43 | |||
44 | /** |
||
45 | * console output |
||
46 | * |
||
47 | * @param string $msg |
||
48 | * @param boolean $newline |
||
49 | * @return void |
||
50 | */ |
||
51 | 2 | public static function output(string $msg, $newline = true) |
|
54 | } |
||
55 | } |
||
56 |