20 lines
419 B
PHP
20 lines
419 B
PHP
<?php
|
|
|
|
namespace App\Support;
|
|
|
|
use RuntimeException;
|
|
|
|
final class CheckedPattern
|
|
{
|
|
/** @return list<string> */
|
|
public static function split(string $pattern, string $value): array
|
|
{
|
|
$parts = preg_split($pattern, $value);
|
|
if ($parts === false) {
|
|
throw new RuntimeException('Text could not be split; original content has been preserved.');
|
|
}
|
|
|
|
return $parts;
|
|
}
|
|
}
|