Mercurial > hg > isophonics-drupal-site
comparison vendor/phpunit/php-code-coverage/src/Report/Xml/Source.php @ 14:1fec387a4317
Update Drupal core to 8.5.2 via Composer
author | Chris Cannam |
---|---|
date | Mon, 23 Apr 2018 09:46:53 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
13:5fb285c0d0e3 | 14:1fec387a4317 |
---|---|
1 <?php | |
2 /* | |
3 * This file is part of the php-code-coverage package. | |
4 * | |
5 * (c) Sebastian Bergmann <sebastian@phpunit.de> | |
6 * | |
7 * For the full copyright and license information, please view the LICENSE | |
8 * file that was distributed with this source code. | |
9 */ | |
10 | |
11 namespace SebastianBergmann\CodeCoverage\Report\Xml; | |
12 | |
13 use TheSeer\Tokenizer\NamespaceUri; | |
14 use TheSeer\Tokenizer\Tokenizer; | |
15 use TheSeer\Tokenizer\XMLSerializer; | |
16 | |
17 class Source | |
18 { | |
19 /** @var \DOMElement */ | |
20 private $context; | |
21 | |
22 /** | |
23 * @param \DOMElement $context | |
24 */ | |
25 public function __construct(\DOMElement $context) | |
26 { | |
27 $this->context = $context; | |
28 } | |
29 | |
30 /** | |
31 * @param string $source | |
32 */ | |
33 public function setSourceCode(string $source) | |
34 { | |
35 $context = $this->context; | |
36 | |
37 $tokens = (new Tokenizer())->parse($source); | |
38 $srcDom = (new XMLSerializer(new NamespaceUri($context->namespaceURI)))->toDom($tokens); | |
39 | |
40 $context->parentNode->replaceChild( | |
41 $context->ownerDocument->importNode($srcDom->documentElement, true), | |
42 $context | |
43 ); | |
44 } | |
45 } |