Skip to content

Commit

Permalink
SUPESC-889 Move strings into constants
Browse files Browse the repository at this point in the history
  • Loading branch information
aleksandr-velikanov committed Sep 11, 2024
1 parent 9ec31bb commit 05d4ea5
Showing 1 changed file with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,21 @@ class GitHubSourceCodeProvider implements SourceCodeProviderInterface
*/
protected const NUMBER_KEY = 'number';

/**
* @var string
*/
protected const STRING_STACK_TRACE = '[stacktrace]';

/**
* @var string
*/
protected const STRING_NUMBER_ONE = '#1';

/**
* @var string
*/
protected const STRING_TRACE_TRUNCATED = '[...trace truncated...]';

/**
* @var \Upgrade\Infrastructure\Configuration\ConfigurationProvider
*/
Expand Down Expand Up @@ -164,20 +179,20 @@ public function buildMessageWithTruncatedTrace(string $message): string
return $message;
}

$messageArray = explode('[stacktrace]', $message);
$messageArray = explode(self::STRING_STACK_TRACE, $message);

if (!isset($messageArray[0]) || !isset($messageArray[1])) {
return $message;
}

$traceArray = explode('#1', $messageArray[1]);
$traceArray = explode(self::STRING_NUMBER_ONE, $messageArray[1]);

if (!isset($traceArray[0])) {
return $message;
}

return $messageArray[0]
. $traceArray[0]
. ('[...trace truncated...]');
. (self::STRING_TRACE_TRUNCATED);
}
}

0 comments on commit 05d4ea5

Please sign in to comment.