@@ -27,31 +27,39 @@ final class TicketSwapErrorFormatter implements ErrorFormatter
27
27
private ErrorFormatter $ ciDetectedErrorFormatter ;
28
28
private ?string $ editorUrl ;
29
29
30
+ /**
31
+ * @param RelativePathHelper $relativePathHelper
32
+ * @param ErrorFormatter $ciDetectedErrorFormatter
33
+ * @param string|null $editorUrl
34
+ * @param array<string, mixed> $environmentVariables
35
+ */
30
36
public function __construct (
31
37
RelativePathHelper $ relativePathHelper ,
32
38
ErrorFormatter $ ciDetectedErrorFormatter ,
33
- ?string $ editorUrl = null
39
+ ?string $ editorUrl ,
40
+ array $ environmentVariables
34
41
) {
35
42
$ this ->relativePathHelper = $ relativePathHelper ;
36
43
$ this ->ciDetectedErrorFormatter = $ ciDetectedErrorFormatter ;
37
44
$ this ->editorUrl = $ editorUrl ;
38
- $ this ->linkFormat = self ::getLinkFormatFromEnv ();
45
+ $ this ->linkFormat = self ::getLinkFormatFromEnv ($ environmentVariables );
39
46
}
40
47
41
48
/**
49
+ * @param array<string, mixed> $environmentVariables
42
50
* @return self::LINK_FORMAT_*
43
51
*/
44
- public static function getLinkFormatFromEnv () : string
52
+ public static function getLinkFormatFromEnv (array $ environmentVariables ) : string
45
53
{
46
- if (getenv ( 'GITHUB_ACTIONS ' ) !== false ) {
54
+ if (isset ( $ environmentVariables [ 'GITHUB_ACTIONS ' ]) ) {
47
55
return self ::LINK_FORMAT_GITHUB_ACTIONS ;
48
56
}
49
57
50
- if (getenv ( 'TERMINAL_EMULATOR ' ) ! == 'JetBrains-JediTerm ' ) {
58
+ if (isset ( $ environmentVariables [ 'TERMINAL_EMULATOR ' ]) && $ environmentVariables [ ' TERMINAL_EMULATOR ' ] = == 'JetBrains-JediTerm ' ) {
51
59
return self ::LINK_FORMAT_PHPSTORM ;
52
60
}
53
61
54
- if (getenv ( 'TERM_PROGRAM ' ) ! == 'WarpTerminal ' ) {
62
+ if (isset ( $ environmentVariables [ 'TERM_PROGRAM ' ]) && $ environmentVariables [ ' TERM_PROGRAM ' ] = == 'WarpTerminal ' ) {
55
63
return self ::LINK_FORMAT_WARP ;
56
64
}
57
65
0 commit comments