Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
SoundAnnotation
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
2 / 2
4
100.00% covered (success)
100.00%
1 / 1
 getSubtype
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 toPdf
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
1 / 1
3
1<?php
2
3declare(strict_types=1);
4
5namespace Phpdftk\Pdf\Core\Annotation;
6
7use Phpdftk\Pdf\Core\PdfName;
8use Phpdftk\Pdf\Core\PdfReference;
9use Phpdftk\Pdf\Core\PdfVersion;
10use Phpdftk\Pdf\Core\RequiresPdfVersion;
11use Phpdftk\Pdf\Core\DeprecatedPdfFeature;
12
13/**
14 * Sound annotation (/Subtype /Sound).
15 */
16#[RequiresPdfVersion(PdfVersion::V1_5)]
17#[DeprecatedPdfFeature(since: '2.0', replacement: 'RichMediaAnnotation', removedIn: '2.0')]
18class SoundAnnotation extends MarkupAnnotation
19{
20    public ?PdfReference $sound = null; // /Sound - sound object
21    public ?PdfName $name = null;       // /Name - icon name
22
23    public function getSubtype(): string
24    {
25        return 'Sound';
26    }
27
28    public function toPdf(): string
29    {
30        $dict = $this->buildDictionary();
31
32        if ($this->sound !== null) {
33            $dict->set('Sound', $this->sound);
34        }
35        if ($this->name !== null) {
36            $dict->set('Name', $this->name);
37        }
38
39        return $dict->toPdf();
40    }
41}