<?php
/**
 * Pattern Block Exception
 * 
 * Custom exception thrown when a request matches a custom pattern
 * 
 * @package VMPFence
 * @subpackage Firewall\Exceptions
 * @since 2.2.0
 */

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

class VMPFence_Pattern_Block_Exception extends Exception {
    private $pattern_type;
    private $pattern_value;
    private $pattern_id;
    
    public function __construct($message, $pattern_type, $pattern_value, $pattern_id) {
        parent::__construct($message);
        $this->pattern_type = $pattern_type;
        $this->pattern_value = $pattern_value;
        $this->pattern_id = $pattern_id;
    }
    
    public function get_pattern_type() {
        return $this->pattern_type;
    }
    
    public function get_pattern_value() {
        return $this->pattern_value;
    }
    
    public function get_pattern_id() {
        return $this->pattern_id;
    }
    
    /**
     * Get violated rules (for compatibility with log_event)
     * Returns pattern info as a "rule" for logging
     */
    public function get_violated_rules() {
        return array(
            array(
                'id' => 'PATTERN_' . $this->pattern_id,
                'description' => 'Custom pattern block: ' . $this->pattern_type,
                'pattern' => $this->pattern_value
            )
        );
    }
}
