• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

sokil / php-vast / 4036941146

pending completion
4036941146

push

github

GitHub
Merge pull request #33 from bramdevries/feature/add-interactive-creative-file

16 of 16 new or added lines in 3 files covered. (100.0%)

356 of 372 relevant lines covered (95.7%)

6.44 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

90.91
/src/Creative/InLine/Linear/InteractiveCreativeFile.php
1
<?php
2
declare(strict_types=1);
3

4
/**
5
 * This file is part of the PHP-VAST package.
6
 *
7
 * (c) Dmytro Sokil <dmytro.sokil@gmail.com>
8
 *
9
 * For the full copyright and license information, please view the LICENSE
10
 * file that was distributed with this source code.
11
 */
12

13
namespace Sokil\Vast\Creative\InLine\Linear;
14

15
/**
16
 * Optional node that enables interactive creative files associated with the ad media (video or audio)
17
 * to be provided to the player.
18
 *
19
 * Compatible with VAST starting from version 4.0
20
 *
21
 * See section 3.9.3 of VAST specification version 4.1
22
 *
23
 * @author Bram Devries <bramdevries93@gmail.com>
24
 */
25
class InteractiveCreativeFile
26
{
27
    /**
28
     * @var \DomElement
29
     */
30
    private $domElement;
31

32
    /**
33
     * @param \DomElement $domElement
34
     */
35
    public function __construct(\DomElement $domElement)
36
    {
37
        $this->domElement = $domElement;
1✔
38
    }
1✔
39

40
    /**
41
     * Set file mime type
42
     *
43
     * @param string $mime Mime type of the file
44
     */
45
    public function setType(string $mime): self
46
    {
47
        $this->domElement->setAttribute('type', $mime);
1✔
48

49
        return $this;
1✔
50
    }
51

52
    /**
53
     * @param string $apiFramework the API needed to execute the resource file if applicable.
54
     */
55
    public function setApiFramework(string $apiFramework): self
56
    {
57
        $this->domElement->setAttribute('apiFramework', $apiFramework);
1✔
58

59
        return $this;
1✔
60
    }
61

62
    /**
63
     * Set file URL
64
     *
65
     * @param string $url URL of the file
66
     */
67
    public function setUrl(string $url): self
68
    {
69
        $cdata = $this->domElement->ownerDocument->createCDATASection($url);
1✔
70

71
        // update CData
72
        if ($this->domElement->hasChildNodes()) {
1✔
73
            $this->domElement->replaceChild($cdata, $this->domElement->firstChild);
×
74
        } // insert CData
75
        else {
76
            $this->domElement->appendChild($cdata);
1✔
77
        }
78
        return $this;
1✔
79
    }
80
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc