t-regx/T-Regx

View on GitHub
src/CleanRegex/Exception/NoSuchNthElementException.php

Summary

Maintainability
A
0 mins
Test Coverage
<?php
namespace TRegx\CleanRegex\Exception;

/**
 * @deprecated
 */
class NoSuchNthElementException extends \RuntimeException implements PatternException
{
    public static function forSubject(int $index, int $total): self
    {
        $message = "Expected to get the $index-nth match";
        if ($total === 0) {
            return new self("$message, but subject was not matched at all");
        }
        return new self("$message, but only $total occurrences were matched");
    }
}