Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
Func
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
1 / 1
 getFunctionType
n/a
0 / 0
n/a
0 / 0
0
 baseDictionary
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
1 / 1
2
1<?php
2
3declare(strict_types=1);
4
5namespace Phpdftk\Pdf\Core\Graphics\Function;
6
7use Phpdftk\Pdf\Core\PdfArray;
8use Phpdftk\Pdf\Core\PdfDictionary;
9use Phpdftk\Pdf\Core\PdfNumber;
10use Phpdftk\Pdf\Core\PdfObject;
11use Phpdftk\Pdf\Core\PdfVersion;
12use Phpdftk\Pdf\Core\RequiresPdfVersion;
13
14/**
15 * Abstract base for PDF function objects (ISO 32000-2 ยง7.10).
16 *
17 * Named `Func` rather than `Function` since `function` is a PHP keyword.
18 * Subclasses are FunctionType0 (sampled), Type2 (exponential),
19 * Type3 (stitching), and Type4 (PostScript calculator).
20 *
21 * Common entries across all function types: FunctionType, Domain, Range.
22 */
23#[RequiresPdfVersion(PdfVersion::V1_3)]
24abstract class Func extends PdfObject
25{
26    public PdfArray $domain;        // /Domain - required
27    public ?PdfArray $range = null; // /Range  - required for types 0 and 4
28
29    abstract public function getFunctionType(): int;
30
31    protected function baseDictionary(): PdfDictionary
32    {
33        $dict = new PdfDictionary();
34        $dict->set('FunctionType', new PdfNumber($this->getFunctionType()));
35        $dict->set('Domain', $this->domain);
36        if ($this->range !== null) {
37            $dict->set('Range', $this->range);
38        }
39        return $dict;
40    }
41}