Debian Codegraph @

vendor/mck89/peast/lib/Peast/Syntax/Node/JSX/JSXAttribute.php

raw
1 <?php
2 /**
3 * This file is part of the Peast package
4 *
5 * (c) Marco Marchiò <[email protected]>
6 *
7 * For the full copyright and license information refer to the LICENSE file
8 * distributed with this source code
9 */
10 namespace Peast\Syntax\Node\JSX;
11
12 use Peast\Syntax\Node\Node;
13
14 /**
15 * A node that represents a JSX attribute.
16 *
17 * @author Marco Marchiò <[email protected]>
18 */
19 class JSXAttribute extends Node
20 {
21 /**
22 * Map of node properties
23 *
24 * @var array
25 */
26 protected $propertiesMap = array(
27 "name" => true,
28 "value" => true
29 );
30
31 /**
32 * Attribute name
33 *
34 * @var JSXIdentifier|JSXNamespacedName
35 */
36 protected $name;
37
38 /**
39 * Attribute value
40 *
41 * @var Node|null
42 */
43 protected $value;
44
45 /**
46 * Returns the attribute name
47 *
48 * @return Node
49 */
50 public function getName()
51 {
52 return $this->name;
53 }
54
55 /**
56 * Sets the attribute name
57 *
58 * @param JSXIdentifier|JSXNamespacedName $name Attribute name
59 *
60 * @return $this
61 */
62 public function setName($name)
63 {
64 $this->assertType($name, array("JSX\\JSXIdentifier", "JSX\\JSXNamespacedName"));
65 $this->name = $name;
66 return $this;
67 }
68
69 /**
70 * Returns the attribute value
71 *
72 * @return Node|null
73 */
74 public function getValue()
75 {
76 return $this->value;
77 }
78
79 /**
80 * Sets the attribute value
81 *
82 * @param Node|null $value Attribute value
83 *
84 * @return $this
85 */
86 public function setValue($value)
87 {
88 $this->assertType(
89 $value,
90 array(
91 "Literal", "JSX\\JSXExpressionContainer",
92 "JSX\\JSXElement", "JSX\\JSXFragment"
93 ),
94 true
95 );
96 $this->value = $value;
97 return $this;
98 }
99 }