| 1 |
<?php |
| 2 |
|
| 3 |
declare (strict_types=1); |
| 4 |
namespace WCPOS\Vendor\Sentry\Util; |
| 5 |
|
| 6 |
use WCPOS\Vendor\Sentry\Options; |
| 7 |
trait PrefixStripper |
| 8 |
{ |
| 9 |
/** |
| 10 |
* Removes from the given file path the specified prefixes in the SDK options. |
| 11 |
*/ |
| 12 |
protected function stripPrefixFromFilePath(?Options $options, string $filePath) : string |
| 13 |
{ |
| 14 |
if ($options === null) { |
| 15 |
return $filePath; |
| 16 |
} |
| 17 |
foreach ($options->getPrefixes() as $prefix) { |
| 18 |
$prefixLength = \strlen($prefix); |
| 19 |
if (\strncmp($filePath, $prefix, $prefixLength) === 0) { |
| 20 |
return \substr($filePath, $prefixLength); |
| 21 |
} |
| 22 |
} |
| 23 |
return $filePath; |
| 24 |
} |
| 25 |
} |
| 26 |
|