File size: 830 Bytes
5f32fbd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php

namespace App\Services\Chatbot;

use Smalot\PdfParser\Parser;

class ParserService
{
    public string $text;

    public string $pdfPath;

    public function __construct(
        public Parser $parser
    ) {}

    public function parse(): string
    {
        $this->setText(
            $this->parser
                ->parseFile($this->getPdfPath())
                ->getText()
        );

        return $this->getText();
    }

    public function setPdfPath(string $pdfPath): ParserService
    {
        $this->pdfPath = $pdfPath;

        return $this;
    }

    public function getPdfPath(): string
    {
        return $this->pdfPath;
    }

    public function getText(): string
    {
        return $this->text;
    }

    public function setText(string $text): void
    {
        $this->text = $text;
    }
}