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

3
.gitignore vendored Normal file
View File

@@ -0,0 +1,3 @@
.devenv/
vendor/
.php-cs-fixer.cache

17
.php-cs-fixer.dist.php Normal file
View File

@@ -0,0 +1,17 @@
<?php
declare(strict_types=1);
use PhpCsFixer\Config;
use PhpCsFixer\Finder;
return (new Config())
->setRiskyAllowed(false)
->setRules([
'@PER-CS' => true
])
->setFinder(
(new Finder())
->in(__DIR__)
)
;

19
composer.json Normal file
View File

@@ -0,0 +1,19 @@
{
"name": "armelnl/scandalous",
"description": "A wrapper around LiteParse for PDF extraction",
"type": "library",
"license": "MIT",
"autoload": {
"psr-4": {
"Scandalous\\": "src/"
}
},
"require": {
"php": "^8.4",
"symfony/process": "^8.1"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.95",
"phpstan/phpstan": "^2.2"
}
}

2926
composer.lock generated Normal file

File diff suppressed because it is too large Load Diff

65
devenv.lock Normal file
View File

@@ -0,0 +1,65 @@
{
"nodes": {
"devenv": {
"locked": {
"dir": "src/modules",
"lastModified": 1780630679,
"narHash": "sha256-hhQyVAYmNKziZ0T+T4Gsk0PYmnz4vdzOzpkJAmDASKM=",
"owner": "cachix",
"repo": "devenv",
"rev": "90ed6227ab389dd4e874a69a724f25dba312b754",
"type": "github"
},
"original": {
"dir": "src/modules",
"owner": "cachix",
"repo": "devenv",
"type": "github"
}
},
"nixpkgs": {
"inputs": {
"nixpkgs-src": "nixpkgs-src"
},
"locked": {
"lastModified": 1778507786,
"narHash": "sha256-HzSQCKMsMr8r55LwM1JuzIOB+8bzk0FEv6sItKvsfoY=",
"owner": "cachix",
"repo": "devenv-nixpkgs",
"rev": "8f24a228a782e24576b155d1e39f0d914b380691",
"type": "github"
},
"original": {
"owner": "cachix",
"ref": "rolling",
"repo": "devenv-nixpkgs",
"type": "github"
}
},
"nixpkgs-src": {
"flake": false,
"locked": {
"lastModified": 1778274207,
"narHash": "sha256-I4puXmX1iovcCHZlRmztO3vW0mAbbRvq4F8wgIMQ1MM=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b3da656039dc7a6240f27b2ef8cc6a3ef3bccae7",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"devenv": "devenv",
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

20
devenv.nix Normal file
View File

@@ -0,0 +1,20 @@
{
pkgs,
lib,
config,
...
}:
{
packages = [
pkgs.liteparse
];
languages = {
php = {
enable = true;
packages = {
composer = pkgs.phpPackages.composer;
};
};
};
}

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);
}
}