Completed
Branch EDTR/master (83b47e)
by
unknown
25:37 queued 16:41
created

PrimaryJsonDataNode::targetScript()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace EventEspresso\core\services\json;
4
5
use DomainException;
6
7
/**
8
 * Class JsonDataNode
9
 * A Root level Data Node that directly targets a script and use case domain that it provides data for
10
 * There can only be one primary data node per request, so care has to be taken to ensure that
11
 * multiple Route objects are not attempting to set a primary data node - THERE CAN ONLY BE ONE !!!
12
 *
13
 * @package EventEspresso\core\services\json
14
 * @author  Brent Christensen
15
 * @since   $VID:$
16
 */
17
abstract class PrimaryJsonDataNode extends JsonDataNode
18
{
19
20
    /**
21
     * wp script handle for the app that requires the JSON data
22
     *
23
     * @var string $target_script
24
     */
25
    private $target_script;
26
27
28
    /**
29
     * sets the WP script handle that this data node is providing data for.
30
     * The JSON data will written to the DOM inline prior to the targeted script handle
31
     *
32
     * @param string $target_script
33
     * @throws DomainException
34
     */
35
    public function setTargetScript($target_script)
36
    {
37
        if ($this->target_script !== null) {
38
            $this->validator->overwriteError($target_script, 'target script');
39
        }
40
        $this->target_script = $target_script;
41
    }
42
43
44
    /**
45
     * the WP script handle that this data node is providing data for
46
     *
47
     * @return string
48
     */
49
    public function targetScript()
50
    {
51
        return $this->target_script;
52
    }
53
}
54