diff --git a/Standard/StandardInterface.php b/Standard/StandardInterface.php new file mode 100644 index 0000000..74ce45a --- /dev/null +++ b/Standard/StandardInterface.php @@ -0,0 +1,16 @@ +getRules() as $rule) { + $errors[get_class($rule)] = $rule->validate($document); + } + + return $errors; + } +} diff --git a/test.php b/test.php index c1ba5c1..77e1fc4 100644 --- a/test.php +++ b/test.php @@ -4,15 +4,9 @@ include 'vendor/autoload.php'; -use Padam87\PdfPreflight\Rule\MaxInkDensityImage; -use Padam87\PdfPreflight\Rule\MaxInkDensityText; -use Padam87\PdfPreflight\Rule\NoRgbImages; -use Padam87\PdfPreflight\Rule\ImageMinDpi; -use Padam87\PdfPreflight\Rule\NoRgbText; -use Padam87\PdfPreflight\Rule\RuleInterface; +use Padam87\PdfPreflight\Standard\X1a; use Smalot\PdfParser\Object as XObject; use Smalot\PdfParser\Parser; -use Symfony\Component\Stopwatch\Stopwatch; use Symfony\Component\VarDumper\Cloner\Stub; use Symfony\Component\VarDumper\Cloner\VarCloner; use Symfony\Component\VarDumper\Dumper\CliDumper; @@ -35,45 +29,12 @@ $dumper->dump($cloner->cloneVar($var)); }); -/** @var RuleInterface[] $rules */ -$rules = [ - new ImageMinDpi(), - new NoRgbImages(), - new NoRgbText(), - new MaxInkDensityImage(300), - new MaxInkDensityText(100), -]; - -$stopwatch = new Stopwatch(); -$stopwatch->start('parse'); - $parser = new Parser(); //$document = $parser->parseFile('./gls.pdf'); -$document = $parser->parseFile('./test.pdf'); - -$event = $stopwatch->stop('parse'); - -dump($event->getDuration()); - -$stopwatch->start('preflight'); - -foreach ($rules as $rule) { - $errors = $rule->validate($document); - - $event = $stopwatch->lap('preflight'); - $periods = $event->getPeriods(); - $period = end($periods); - - dump( - [ - 'rule' => get_class($rule), - 'errors' => $errors, - 'duration' => $period->getDuration(), - ] - ); -} +//$document = $parser->parseFile('./test.pdf'); +$document = $parser->parseFile('./hotel.pdf'); -$event = $stopwatch->stop('preflight'); +$standard = new X1a(); -dump($event->getDuration()); +dump($standard->validate($document));