Files
rspade_system/app/RSpade/SchemaQuality/Rules/Schema_Rule_Abstract.php
root 29c657f7a7 Exclude tests directory from framework publish
Add 100+ automated unit tests from .expect file specifications
Add session system test
Add rsx:constants:regenerate command test
Add rsx:logrotate command test
Add rsx:clean command test
Add rsx:manifest:stats command test
Add model enum system test
Add model mass assignment prevention test
Add rsx:check command test
Add migrate:status command test

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-25 03:59:58 +00:00

77 lines
1.7 KiB
PHP

<?php
namespace App\RSpade\SchemaQuality\Rules;
use App\RSpade\SchemaQuality\SchemaViolation;
abstract class Schema_Rule_Abstract
{
protected array $violations = [];
protected array $excluded_tables = ['_migrations', '_sessions'];
/**
* Get the unique rule identifier
*/
abstract public function get_id(): string;
/**
* Get human-readable rule name
*/
abstract public function get_name(): string;
/**
* Get rule description
*/
abstract public function get_description(): string;
/**
* Check the schema for violations
*
* @param array $schema Database schema information
*/
abstract public function check(array $schema): void;
/**
* Check if a table should be excluded from checks
*/
protected function is_excluded_table(string $table): bool
{
return in_array($table, $this->excluded_tables);
}
/**
* Add a violation
*/
protected function add_violation(
string $table,
?string $column,
string $message,
string $recommendation,
string $severity = 'high'
): void {
$this->violations[] = new SchemaViolation(
rule_id: $this->get_id(),
table: $table,
column: $column,
message: $message,
recommendation: $recommendation,
severity: $severity
);
}
/**
* Get all violations found
*/
public function get_violations(): array
{
return $this->violations;
}
/**
* Clear violations
*/
public function clear_violations(): void
{
$this->violations = [];
}
}