<commit_before><?php

namespace App\Controller;

use App\Entity\AttachmentFile;
use Core\Utils\EntityFinder;

class Attachment
{
    public function index($id)
    {
        /** @var AttachmentFile */
        $attachment = EntityFinder::findById(AttachmentFile::class, $id);

        header('Content-Type: application/octet-stream');
        header('Content-Disposition: attachment; filename="' . $attachment->getName() . '"');<commit_msg>[Issue #11] 첨부파일이 DB에 없는 경우 예외처리<commit_after><?php

namespace App\Controller;

use App\Entity\AttachmentFile;
use Core\Utils\EntityFinder;
use \Exception;

class Attachment
{
    public function index($id)
    {
        /** @var AttachmentFile */
        $attachment = EntityFinder::findById(AttachmentFile::class, $id);

        if ($attachment === null) {
            throw new Exception('Attachment is not found!');
        }

        header('Content-Type: application/octet-stream');
        header('Content-Disposition: attachment; filename="' . $attachment->getName() . '"');
{'fraction_non_alphanumeric': 0.14397649363369247, 'fraction_numerical': 0.0019588638589618022, 'mean_word_length': 3.502202643171806, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6229012', 'n_tokens_mistral': 298, 'n_tokens_neox': 311, 'n_words': 63}