-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathInvoiceSplitterV1InvoicePageGroup.php
More file actions
66 lines (57 loc) · 1.86 KB
/
Copy pathInvoiceSplitterV1InvoicePageGroup.php
File metadata and controls
66 lines (57 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
declare(strict_types=1);
namespace Mindee\V1\Product\InvoiceSplitter;
use Mindee\V1\Parsing\Standard\FieldConfidenceMixin;
use Mindee\V1\Parsing\Standard\FieldPositionMixin;
use Mindee\V1\Parsing\SummaryHelperV1;
use Stringable;
/**
* List of page groups. Each group represents a single invoice within a multi-invoice document.
*/
class InvoiceSplitterV1InvoicePageGroup implements Stringable
{
use FieldConfidenceMixin;
use FieldPositionMixin;
/**
* @var integer[] List of page indexes that belong to the same invoice (group).
*/
public array $pageIndexes;
/**
* @param array<string, int|float|string|bool|null|array<array-key, mixed>> $rawPrediction Array containing the JSON document response.
* @param integer|null $pageId Page number for multi pages document.
*/
public function __construct(array $rawPrediction, public ?int $pageId)
{
$this->setConfidence($rawPrediction);
$this->setPosition($rawPrediction);
$this->pageIndexes = $rawPrediction["page_indexes"] ?? [];
}
/**
* Return values for printing inside an RST table.
* @return array<string, string>
*/
private function tablePrintableValues(): array
{
$outArr = [];
$outArr["pageIndexes"] = implode(", ", $this->pageIndexes);
return $outArr;
}
/**
* Output in a format suitable for inclusion in an rST table.
*
*/
public function toTableLine(): string
{
$printable = $this->tablePrintableValues();
$outStr = "| ";
$outStr .= SummaryHelperV1::padString($printable["pageIndexes"], 72);
return rtrim(SummaryHelperV1::cleanOutString($outStr));
}
/**
* @return string String representation.
*/
public function __toString(): string
{
return SummaryHelperV1::cleanOutString($this->toTableLine());
}
}