pdftract/sdk/php/src/Pdftract/Models/Destination.php
jedarden 246befd8d1 feat(pdftract-2m3gl): implement PHP SDK with Packagist publishing
- Add jedarden/pdftract Composer package (sdk/php/)
- Implement Client.php with proc_open subprocess execution
- Add PSR-3 LoggerInterface integration (defaults to NullLogger)
- Add 9 contract methods: extract, extractText, extractMarkdown, extractStream, search, getMetadata, hash, classify, verifyReceipt
- Add readonly model classes: Document, Page, Metadata, Fingerprint, Classification, Match, Receipt
- Add exception classes: PdftractException base + 8 subclasses
- Add PHPUnit conformance test suite
- Add phpunit.xml configuration
- Add composer.json with jedarden/pdftract package name
- Add .ci/argo-workflows/pdftract-php-publish.yaml (Packagist auto-discovery from git tags)

Also includes Ruby SDK scaffold from parallel workflow.

Closes pdftract-2m3gl
2026-06-01 10:27:03 -04:00

96 lines
2.1 KiB
PHP

<?php
declare(strict_types=1);
namespace Jedarden\Pdftract\Models;
/**
* JSON representation of a destination anchor
*
* Describes a specific location within a PDF page.
*/
class Destination
{
/**
* Destination type: "xyz", "fit", "fith", "fitv", "fitr", "fitb", "fitbh", "fitbv"
*/
public string $type;
/**
* Left coordinate (user-space points), present for "xyz", "fitv", "fitr", "fitbv"
*/
public ?float $left = null;
/**
* Top coordinate (user-space points), present for "xyz", "fith", "fitr", "fitbh"
*/
public ?float $top = null;
/**
* Right coordinate (user-space points), present only for "fitr"
*/
public ?float $right = null;
/**
* Bottom coordinate (user-space points), present only for "fitr"
*/
public ?float $bottom = null;
/**
* Zoom factor, present only for "xyz"
*/
public ?float $zoom = null;
/**
* Create Destination from JSON array
*
* @param array<string,mixed> $data JSON data
* @return self
*/
public static function fromArray(array $data): self
{
$dest = new self();
$dest->type = $data['type'];
$dest->left = $data['left'] ?? null;
$dest->top = $data['top'] ?? null;
$dest->right = $data['right'] ?? null;
$dest->bottom = $data['bottom'] ?? null;
$dest->zoom = $data['zoom'] ?? null;
return $dest;
}
/**
* Convert to JSON array
*
* @return array<string,mixed>
*/
public function toArray(): array
{
$data = [
'type' => $this->type,
];
if ($this->left !== null) {
$data['left'] = $this->left;
}
if ($this->top !== null) {
$data['top'] = $this->top;
}
if ($this->right !== null) {
$data['right'] = $this->right;
}
if ($this->bottom !== null) {
$data['bottom'] = $this->bottom;
}
if ($this->zoom !== null) {
$data['zoom'] = $this->zoom;
}
return $data;
}
}