3
3
namespace DivineOmega \HCLParser ;
4
4
5
5
/**
6
- * Class Installer
7
- * @package DivineOmega\HCLParser
6
+ * Class Installer.
8
7
*/
9
8
abstract class Installer
10
9
{
11
10
/**
12
- * json2hcl Version we want to use
11
+ * json2hcl Version we want to use.
12
+ *
13
13
* @see https://github.com/kvz/json2hcl/releases
14
14
*/
15
15
const JSON2HCL_VERSION = '0.0.6 ' ;
16
16
17
17
/**
18
- * Returns the correct binary filename according to the Operating System and Architecture
18
+ * Returns the correct binary filename according to the Operating System and Architecture.
19
19
*/
20
20
public static function getBinaryFilename ()
21
21
{
22
- # Defaults
22
+ // Defaults
23
23
$ osString = 'linux ' ;
24
24
$ architecture = 'amd64 ' ;
25
25
26
- # Switch architecture if needed
26
+ // Switch architecture if needed
27
27
if (2147483647 == PHP_INT_MAX ) {
28
28
$ architecture = '386 ' ;
29
29
}
30
30
31
- # Switch Operating System if needed
32
- switch (TRUE ) {
31
+ // Switch Operating System if needed
32
+ switch (true ) {
33
33
case stristr (PHP_OS , 'DAR ' ):
34
34
$ osString = 'darwin ' ;
35
35
break ;
@@ -38,27 +38,27 @@ public static function getBinaryFilename()
38
38
break ;
39
39
}
40
40
41
- return sprintf ('json2hcl_v%s_%s_%s ' ,self ::JSON2HCL_VERSION , $ osString , $ architecture );
41
+ return sprintf ('json2hcl_v%s_%s_%s ' , self ::JSON2HCL_VERSION , $ osString , $ architecture );
42
42
}
43
43
44
44
public static function installBinaries ()
45
45
{
46
46
$ binaryUrls = [
47
- sprintf ('https://github.com/kvz/json2hcl/releases/download/v%s/%s ' , self ::JSON2HCL_VERSION , self ::getBinaryFilename () )
47
+ sprintf ('https://github.com/kvz/json2hcl/releases/download/v%s/%s ' , self ::JSON2HCL_VERSION , self ::getBinaryFilename ()),
48
48
];
49
49
50
50
foreach ($ binaryUrls as $ binaryUrl ) {
51
- $ destination = __DIR__ . '/../bin/ ' . basename ($ binaryUrl );
51
+ $ destination = __DIR__ . '/../bin/ ' . basename ($ binaryUrl );
52
52
53
- # Skip if file exists
53
+ // Skip if file exists
54
54
if (file_exists ($ destination )) {
55
55
continue ;
56
56
}
57
57
58
- # Download
58
+ // Download
59
59
file_put_contents ($ destination , file_get_contents ($ binaryUrl ));
60
60
61
- # Make executable
61
+ // Make executable
62
62
chmod ($ destination , 0755 );
63
63
}
64
64
}
0 commit comments