<?php

namespace App\Modules\HR\Recruitment\DTOs;

final readonly class InterviewScorecardWriteData
{
    public function __construct(
        public int $interviewId,
        public int $overallScore,
        public string $recommendation,
        public ?string $strengths,
        public ?string $weaknesses,
        public ?string $notes,
    ) {}

    /** @param  array<string, mixed>  $data */
    public static function fromValidated(array $data): self
    {
        return new self(
            interviewId: (int) $data['interview_id'],
            overallScore: (int) $data['overall_score'],
            recommendation: (string) $data['recommendation'],
            strengths: isset($data['strengths']) ? (string) $data['strengths'] : null,
            weaknesses: isset($data['weaknesses']) ? (string) $data['weaknesses'] : null,
            notes: isset($data['notes']) ? (string) $data['notes'] : null,
        );
    }

    /** @return array<string, mixed> */
    public function toArray(): array
    {
        return [
            'interview_id' => $this->interviewId,
            'overall_score' => $this->overallScore,
            'recommendation' => $this->recommendation,
            'strengths' => $this->strengths,
            'weaknesses' => $this->weaknesses,
            'notes' => $this->notes,
        ];
    }
}
