<?php

namespace MatthiasMullie\Minify\Exceptions;

if ( ! defined( 'ABSPATH' ) ) {
    exit;
}

class PatternMatchException extends BasicException {
    public static function fromLastError(string $message = ''): self {
        if (function_exists('preg_last_error_msg')) {
            $detail = preg_last_error_msg();
        } else {
            $detail = 'PCRE error code ' . preg_last_error();
        }

        return new self(trim($message . ' ' . $detail));
    }
}
