<?php

require_once __DIR__ . "/PDFProcessor.php";

class PageCounter
{

    private PDFProcessor $pdf;

    public function __construct()
    {

        $this->pdf = new PDFProcessor();

    }

    /**
     * Count Pages
     */
    public function count(string $pdfFile): array
    {

        $result = $this->pdf->load($pdfFile);

        if (!$result["success"]) {

            return $result;

        }

        $document = $result["document"];

        $pages = $document->getPages();

        return [

            "success" => true,

            "pages" => count($pages)

        ];

    }

}