@@ -27,31 +27,39 @@ final class TicketSwapErrorFormatter implements ErrorFormatter
2727 private ErrorFormatter $ ciDetectedErrorFormatter ;
2828 private ?string $ editorUrl ;
2929
30+ /**
31+ * @param RelativePathHelper $relativePathHelper
32+ * @param ErrorFormatter $ciDetectedErrorFormatter
33+ * @param string|null $editorUrl
34+ * @param array<string, mixed> $environmentVariables
35+ */
3036 public function __construct (
3137 RelativePathHelper $ relativePathHelper ,
3238 ErrorFormatter $ ciDetectedErrorFormatter ,
33- ?string $ editorUrl = null
39+ ?string $ editorUrl ,
40+ array $ environmentVariables
3441 ) {
3542 $ this ->relativePathHelper = $ relativePathHelper ;
3643 $ this ->ciDetectedErrorFormatter = $ ciDetectedErrorFormatter ;
3744 $ this ->editorUrl = $ editorUrl ;
38- $ this ->linkFormat = self ::getLinkFormatFromEnv ();
45+ $ this ->linkFormat = self ::getLinkFormatFromEnv ($ environmentVariables );
3946 }
4047
4148 /**
49+ * @param array<string, mixed> $environmentVariables
4250 * @return self::LINK_FORMAT_*
4351 */
44- public static function getLinkFormatFromEnv () : string
52+ public static function getLinkFormatFromEnv (array $ environmentVariables ) : string
4553 {
46- if (getenv ( 'GITHUB_ACTIONS ' ) !== false ) {
54+ if (isset ( $ environmentVariables [ 'GITHUB_ACTIONS ' ]) ) {
4755 return self ::LINK_FORMAT_GITHUB_ACTIONS ;
4856 }
4957
50- if (getenv ( 'TERMINAL_EMULATOR ' ) ! == 'JetBrains-JediTerm ' ) {
58+ if (isset ( $ environmentVariables [ 'TERMINAL_EMULATOR ' ]) && $ environmentVariables [ ' TERMINAL_EMULATOR ' ] = == 'JetBrains-JediTerm ' ) {
5159 return self ::LINK_FORMAT_PHPSTORM ;
5260 }
5361
54- if (getenv ( 'TERM_PROGRAM ' ) ! == 'WarpTerminal ' ) {
62+ if (isset ( $ environmentVariables [ 'TERM_PROGRAM ' ]) && $ environmentVariables [ ' TERM_PROGRAM ' ] = == 'WarpTerminal ' ) {
5563 return self ::LINK_FORMAT_WARP ;
5664 }
5765
0 commit comments