[ Index ] |
PHP Cross Reference of phpBB-3.3.14-deutsch |
[Summary view] [Print] [Text view]
1 <?php 2 3 /* 4 * This file is part of the Symfony package. 5 * 6 * (c) Fabien Potencier <fabien@symfony.com> 7 * 8 * For the full copyright and license information, please view the LICENSE 9 * file that was distributed with this source code. 10 */ 11 12 namespace Symfony\Component\HttpKernel\Profiler; 13 14 use Symfony\Component\HttpKernel\DataCollector\DataCollectorInterface; 15 16 /** 17 * Profile. 18 * 19 * @author Fabien Potencier <fabien@symfony.com> 20 */ 21 class Profile 22 { 23 private $token; 24 25 /** 26 * @var DataCollectorInterface[] 27 */ 28 private $collectors = []; 29 30 private $ip; 31 private $method; 32 private $url; 33 private $time; 34 private $statusCode; 35 36 /** 37 * @var Profile 38 */ 39 private $parent; 40 41 /** 42 * @var Profile[] 43 */ 44 private $children = []; 45 46 /** 47 * @param string $token The token 48 */ 49 public function __construct($token) 50 { 51 $this->token = $token; 52 } 53 54 /** 55 * Sets the token. 56 * 57 * @param string $token The token 58 */ 59 public function setToken($token) 60 { 61 $this->token = $token; 62 } 63 64 /** 65 * Gets the token. 66 * 67 * @return string The token 68 */ 69 public function getToken() 70 { 71 return $this->token; 72 } 73 74 /** 75 * Sets the parent token. 76 */ 77 public function setParent(self $parent) 78 { 79 $this->parent = $parent; 80 } 81 82 /** 83 * Returns the parent profile. 84 * 85 * @return self 86 */ 87 public function getParent() 88 { 89 return $this->parent; 90 } 91 92 /** 93 * Returns the parent token. 94 * 95 * @return string|null The parent token 96 */ 97 public function getParentToken() 98 { 99 return $this->parent ? $this->parent->getToken() : null; 100 } 101 102 /** 103 * Returns the IP. 104 * 105 * @return string|null The IP 106 */ 107 public function getIp() 108 { 109 return $this->ip; 110 } 111 112 /** 113 * Sets the IP. 114 * 115 * @param string $ip 116 */ 117 public function setIp($ip) 118 { 119 $this->ip = $ip; 120 } 121 122 /** 123 * Returns the request method. 124 * 125 * @return string|null The request method 126 */ 127 public function getMethod() 128 { 129 return $this->method; 130 } 131 132 public function setMethod($method) 133 { 134 $this->method = $method; 135 } 136 137 /** 138 * Returns the URL. 139 * 140 * @return string|null The URL 141 */ 142 public function getUrl() 143 { 144 return $this->url; 145 } 146 147 /** 148 * @param string $url 149 */ 150 public function setUrl($url) 151 { 152 $this->url = $url; 153 } 154 155 /** 156 * Returns the time. 157 * 158 * @return int The time 159 */ 160 public function getTime() 161 { 162 if (null === $this->time) { 163 return 0; 164 } 165 166 return $this->time; 167 } 168 169 /** 170 * @param int $time The time 171 */ 172 public function setTime($time) 173 { 174 $this->time = $time; 175 } 176 177 /** 178 * @param int $statusCode 179 */ 180 public function setStatusCode($statusCode) 181 { 182 $this->statusCode = $statusCode; 183 } 184 185 /** 186 * @return int|null 187 */ 188 public function getStatusCode() 189 { 190 return $this->statusCode; 191 } 192 193 /** 194 * Finds children profilers. 195 * 196 * @return self[] 197 */ 198 public function getChildren() 199 { 200 return $this->children; 201 } 202 203 /** 204 * Sets children profiler. 205 * 206 * @param Profile[] $children 207 */ 208 public function setChildren(array $children) 209 { 210 $this->children = []; 211 foreach ($children as $child) { 212 $this->addChild($child); 213 } 214 } 215 216 /** 217 * Adds the child token. 218 */ 219 public function addChild(self $child) 220 { 221 $this->children[] = $child; 222 $child->setParent($this); 223 } 224 225 /** 226 * Gets a Collector by name. 227 * 228 * @param string $name A collector name 229 * 230 * @return DataCollectorInterface A DataCollectorInterface instance 231 * 232 * @throws \InvalidArgumentException if the collector does not exist 233 */ 234 public function getCollector($name) 235 { 236 if (!isset($this->collectors[$name])) { 237 throw new \InvalidArgumentException(sprintf('Collector "%s" does not exist.', $name)); 238 } 239 240 return $this->collectors[$name]; 241 } 242 243 /** 244 * Gets the Collectors associated with this profile. 245 * 246 * @return DataCollectorInterface[] 247 */ 248 public function getCollectors() 249 { 250 return $this->collectors; 251 } 252 253 /** 254 * Sets the Collectors associated with this profile. 255 * 256 * @param DataCollectorInterface[] $collectors 257 */ 258 public function setCollectors(array $collectors) 259 { 260 $this->collectors = []; 261 foreach ($collectors as $collector) { 262 $this->addCollector($collector); 263 } 264 } 265 266 /** 267 * Adds a Collector. 268 */ 269 public function addCollector(DataCollectorInterface $collector) 270 { 271 $this->collectors[$collector->getName()] = $collector; 272 } 273 274 /** 275 * Returns true if a Collector for the given name exists. 276 * 277 * @param string $name A collector name 278 * 279 * @return bool 280 */ 281 public function hasCollector($name) 282 { 283 return isset($this->collectors[$name]); 284 } 285 286 public function __sleep() 287 { 288 return ['token', 'parent', 'children', 'collectors', 'ip', 'method', 'url', 'time', 'statusCode']; 289 } 290 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Mon Nov 25 19:05:08 2024 | Cross-referenced by PHPXref 0.7.1 |