source: trunk/client/inc/hpdf5/spipu/html2pdf/src/Parsing/Node.php@ 398

Last change on this file since 398 was 347, checked in by roby, 3 years ago

Aggiornamento per compatibilità con php7.4

File size: 2.9 KB
Line 
1<?php
2/**
3 * Html2Pdf Library
4 *
5 * HTML => PDF convertor
6 * distributed under the OSL-3.0 License
7 *
8 * @package Html2pdf
9 * @author Laurent MINGUET <webmaster@html2pdf.fr>
10 * @copyright 2017 Laurent MINGUET
11 */
12namespace Spipu\Html2Pdf\Parsing;
13
14/**
15 * Class Node
16 *
17 * Represent an DOM node in the document
18 */
19class Node
20{
21 /**
22 * @var string
23 */
24 private $name;
25
26 /**
27 * @var array
28 */
29 private $params;
30
31 /**
32 * @var bool
33 */
34 private $close;
35
36 /**
37 * @var bool
38 */
39 private $autoClose;
40
41 /**
42 * @var int
43 */
44 private $line;
45
46 /**
47 * @param string $name
48 * @param array $params
49 * @param bool $close
50 * @param bool $autoClose
51 */
52 public function __construct($name, $params, $close, $autoClose = false)
53 {
54 $this->setName($name);
55 $this->setParams($params);
56 $this->setClose($close);
57 $this->setAutoClose($autoClose);
58 }
59
60 /**
61 * @return mixed
62 */
63 public function getName()
64 {
65 return $this->name;
66 }
67
68 /**
69 * @param string $name
70 */
71 public function setName($name)
72 {
73 $this->name = $name;
74 }
75
76 /**
77 * @return array
78 */
79 public function getParams()
80 {
81 return $this->params;
82 }
83
84 /**
85 * @param string $key
86 * @param mixed $default
87 *
88 * @return null
89 */
90 public function getParam($key, $default = null)
91 {
92 if (array_key_exists($key, $this->params)) {
93 return $this->params[$key];
94 }
95 return $default;
96 }
97
98 /**
99 * Get a style
100 * @param string $key
101 * @param string|null $default
102 *
103 * @return string|null
104 */
105 public function getStyle($key, $default = null)
106 {
107 $styles = $this->getParam('style', []);
108
109 if (array_key_exists($key, $styles)) {
110 return $styles[$key];
111 }
112 return $default;
113 }
114
115 /**
116 * @param string $key
117 * @param mixed $value
118 *
119 * @return mixed
120 */
121 public function setParam($key, $value)
122 {
123 return $this->params[$key] = $value;
124 }
125
126 /**
127 * @param array $params
128 */
129 public function setParams($params)
130 {
131 $this->params = $params;
132 }
133
134 /**
135 * @return bool
136 */
137 public function isClose()
138 {
139 return $this->close;
140 }
141
142 /**
143 * @param bool $close
144 */
145 public function setClose($close)
146 {
147 $this->close = (bool) $close;
148 }
149 /**
150 * @return bool
151 */
152 public function isAutoClose()
153 {
154 return $this->autoClose;
155 }
156
157 /**
158 * @param $autoClose
159 */
160 public function setAutoClose($autoClose)
161 {
162 $this->autoClose = (bool) $autoClose;
163 }
164
165 /**
166 * @return int
167 */
168 public function getLine()
169 {
170 return $this->line;
171 }
172
173 /**
174 * @param int $line
175 */
176 public function setLine($line)
177 {
178 $this->line = $line;
179 }
180}
Note: See TracBrowser for help on using the repository browser.