public static function matchAll($pattern, $subject, $offset = 0)
{
$matches = [];
$subject = substr($subject, $offset);
preg_match_all($pattern, $subject, $matches, PREG_PATTERN_ORDER);
$fullMatches = reset($matches);
if (empty($fullMatches)) {
return;
}
if (count($fullMatches) === 1) {
foreach ($matches as &$match) {
$match = reset($match);
}
}
if (!empty($matches)) {
return $matches;
}
}