[ Index ] |
PHP Cross Reference of phpBB-3.1.12-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 = array(); 29 30 private $ip; 31 private $method; 32 private $url; 33 private $time; 34 35 /** 36 * @var Profile 37 */ 38 private $parent; 39 40 /** 41 * @var Profile[] 42 */ 43 private $children = array(); 44 45 /** 46 * Constructor. 47 * 48 * @param string $token The token 49 */ 50 public function __construct($token) 51 { 52 $this->token = $token; 53 } 54 55 /** 56 * Sets the token. 57 * 58 * @param string $token The token 59 */ 60 public function setToken($token) 61 { 62 $this->token = $token; 63 } 64 65 /** 66 * Gets the token. 67 * 68 * @return string The token 69 */ 70 public function getToken() 71 { 72 return $this->token; 73 } 74 75 /** 76 * Sets the parent token. 77 * 78 * @param Profile $parent The parent Profile 79 */ 80 public function setParent(Profile $parent) 81 { 82 $this->parent = $parent; 83 } 84 85 /** 86 * Returns the parent profile. 87 * 88 * @return Profile The parent profile 89 */ 90 public function getParent() 91 { 92 return $this->parent; 93 } 94 95 /** 96 * Returns the parent token. 97 * 98 * @return null|string The parent token 99 */ 100 public function getParentToken() 101 { 102 return $this->parent ? $this->parent->getToken() : null; 103 } 104 105 /** 106 * Returns the IP. 107 * 108 * @return string The IP 109 */ 110 public function getIp() 111 { 112 return $this->ip; 113 } 114 115 /** 116 * Sets the IP. 117 * 118 * @param string $ip 119 */ 120 public function setIp($ip) 121 { 122 $this->ip = $ip; 123 } 124 125 /** 126 * Returns the request method. 127 * 128 * @return string The request method 129 */ 130 public function getMethod() 131 { 132 return $this->method; 133 } 134 135 public function setMethod($method) 136 { 137 $this->method = $method; 138 } 139 140 /** 141 * Returns the URL. 142 * 143 * @return string The URL 144 */ 145 public function getUrl() 146 { 147 return $this->url; 148 } 149 150 public function setUrl($url) 151 { 152 $this->url = $url; 153 } 154 155 /** 156 * Returns the time. 157 * 158 * @return string 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 public function setTime($time) 170 { 171 $this->time = $time; 172 } 173 174 /** 175 * Finds children profilers. 176 * 177 * @return Profile[] An array of Profile 178 */ 179 public function getChildren() 180 { 181 return $this->children; 182 } 183 184 /** 185 * Sets children profiler. 186 * 187 * @param Profile[] $children An array of Profile 188 */ 189 public function setChildren(array $children) 190 { 191 $this->children = array(); 192 foreach ($children as $child) { 193 $this->addChild($child); 194 } 195 } 196 197 /** 198 * Adds the child token. 199 * 200 * @param Profile $child The child Profile 201 */ 202 public function addChild(Profile $child) 203 { 204 $this->children[] = $child; 205 $child->setParent($this); 206 } 207 208 /** 209 * Gets a Collector by name. 210 * 211 * @param string $name A collector name 212 * 213 * @return DataCollectorInterface A DataCollectorInterface instance 214 * 215 * @throws \InvalidArgumentException if the collector does not exist 216 */ 217 public function getCollector($name) 218 { 219 if (!isset($this->collectors[$name])) { 220 throw new \InvalidArgumentException(sprintf('Collector "%s" does not exist.', $name)); 221 } 222 223 return $this->collectors[$name]; 224 } 225 226 /** 227 * Gets the Collectors associated with this profile. 228 * 229 * @return DataCollectorInterface[] 230 */ 231 public function getCollectors() 232 { 233 return $this->collectors; 234 } 235 236 /** 237 * Sets the Collectors associated with this profile. 238 * 239 * @param DataCollectorInterface[] $collectors 240 */ 241 public function setCollectors(array $collectors) 242 { 243 $this->collectors = array(); 244 foreach ($collectors as $collector) { 245 $this->addCollector($collector); 246 } 247 } 248 249 /** 250 * Adds a Collector. 251 * 252 * @param DataCollectorInterface $collector A DataCollectorInterface instance 253 */ 254 public function addCollector(DataCollectorInterface $collector) 255 { 256 $this->collectors[$collector->getName()] = $collector; 257 } 258 259 /** 260 * Returns true if a Collector for the given name exists. 261 * 262 * @param string $name A collector name 263 * 264 * @return bool 265 */ 266 public function hasCollector($name) 267 { 268 return isset($this->collectors[$name]); 269 } 270 271 public function __sleep() 272 { 273 return array('token', 'parent', 'children', 'collectors', 'ip', 'method', 'url', 'time'); 274 } 275 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Jan 11 00:25:41 2018 | Cross-referenced by PHPXref 0.7.1 |