<?php

declare(strict_types=1);

namespace App\Knowledge\Extractor;

use Smalot\PdfParser\Parser;

final class PdfExtractor implements DocumentExtractorInterface
{
    public function supports(string $extension): bool
    {
        return strtolower($extension) === 'pdf';
    }

    public function extract(string $path): string
    {
        $parser = new Parser();
        $pdf = $parser->parseFile($path);

        return $pdf->getText();
    }
}
