<?php

namespace mystic\forum\attributes;

#[\Attribute(\Attribute::TARGET_PROPERTY)]
class References {
    public function __construct(
        public readonly string $foreignTableName,
        public readonly ?string $foreignColumnName = null,
        public readonly bool $cascadeOnDelete = false,
    ) {}

    public function __toString(): string {
        return $this->foreignTableName
            . ($this->foreignColumnName !== null ? " ({$this->foreignColumnName})" : "")
            . ($this->cascadeOnDelete ? " ON DELETE CASCADE" : "");
    }
}