trafficmonitor/app/Entities/TrafficEntity.php
2025-11-13 09:15:13 +09:00

57 lines
1.5 KiB
PHP

<?php
namespace App\Entities;
use App\Models\TrafficModel;
/**
* 모니터링 대상 장비/인터페이스 정보를 담는 엔티티
*/
class TrafficEntity extends CommonEntity
{
const PK = TrafficModel::PK;
const TITLE = TrafficModel::TITLE;
//기본기능용
protected $casts = [
// 'role' => 'json-array', // 🚫 CSV 형식 저장을 위해 제거
];
public function getClient(): string
{
return $this->attributes['client'];
}
public function getSwitch(): string
{
return $this->attributes['swtich'];
}
public function getServer(): string
{
return $this->attributes['server'];
}
public function getServerIP(): string
{
return $this->attributes['server_ip'];
}
//SwitchIP
public function getIP(): string
{
return $this->attributes['ip'];
}
public function getInterface(): string
{
return $this->attributes['interface'];
}
public function getCommunity(): string
{
return $this->attributes['community'] ?? 'public';
}
// Setter 예시: IP 주소 설정 시 유효성 검사 또는 로직 추가 가능
public function setIP(string $ip): void
{
// 예시: IP 주소 유효성 검사 로직 추가 가능
if (filter_var($ip, FILTER_VALIDATE_IP) === false) {
throw new \InvalidArgumentException("유효하지 않은 IP 주소입니다.");
}
$this->attributes['ip'] = $ip;
}
}