Initial commit

This commit is contained in:
2026-06-05 23:40:26 +02:00
commit ebf977cf48
11 changed files with 3131 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
<?php
declare(strict_types=1);
namespace Scandalous\Contract;
interface ProcessRunnerInterface
{
/** @param string[] $command */
public function run(array $command): string;
}

View File

@@ -0,0 +1,10 @@
<?php
declare(strict_types=1);
namespace Scandalous\Contract;
interface TextExtractorInterface
{
public function extract(string $file): string;
}

View File

@@ -0,0 +1,21 @@
<?php
declare(strict_types=1);
namespace Scandalous\Engine;
use Scandalous\Contract\ProcessRunnerInterface;
use Scandalous\Contract\TextExtractorInterface;
final class LiteParseExtractor implements TextExtractorInterface
{
public function __construct(
private ProcessRunnerInterface $runner,
private string $binary = 'lit',
) {}
public function extract(string $file): string
{
return $this->runner->run([$this->binary, 'parse', $file]);
}
}

View File

@@ -0,0 +1,20 @@
<?php
declare(strict_types=1);
namespace Scandalous\Process;
use Scandalous\Contract\ProcessRunnerInterface;
use Symfony\Component\Process\Process;
final class ProcessRunner implements ProcessRunnerInterface
{
/** @param string[] $command */
public function run(array $command): string
{
$process = new Process($command);
$process->mustRun();
return $process->getOutput();
}
}

19
src/Scandalous.php Normal file
View File

@@ -0,0 +1,19 @@
<?php
declare(strict_types=1);
namespace Scandalous;
use Scandalous\Contract\TextExtractorInterface;
class Scandalous
{
public function __construct(
private readonly TextExtractorInterface $extractor,
) {}
public function extract(string $pdfPath): string
{
return $this->extractor->extract($pdfPath);
}
}