| 148 |
lars |
1 |
<?php declare(strict_types=1);
|
|
|
2 |
/*
|
|
|
3 |
* This file is part of phpunit/php-code-coverage.
|
|
|
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 |
namespace SebastianBergmann\CodeCoverage\Report\Xml;
|
|
|
11 |
|
|
|
12 |
use DOMElement;
|
|
|
13 |
|
|
|
14 |
/**
|
|
|
15 |
* @internal This class is not covered by the backward compatibility promise for phpunit/php-code-coverage
|
|
|
16 |
*/
|
|
|
17 |
final class Method
|
|
|
18 |
{
|
|
|
19 |
/**
|
|
|
20 |
* @var DOMElement
|
|
|
21 |
*/
|
|
|
22 |
private $contextNode;
|
|
|
23 |
|
|
|
24 |
public function __construct(DOMElement $context, string $name)
|
|
|
25 |
{
|
|
|
26 |
$this->contextNode = $context;
|
|
|
27 |
|
|
|
28 |
$this->setName($name);
|
|
|
29 |
}
|
|
|
30 |
|
|
|
31 |
public function setSignature(string $signature): void
|
|
|
32 |
{
|
|
|
33 |
$this->contextNode->setAttribute('signature', $signature);
|
|
|
34 |
}
|
|
|
35 |
|
|
|
36 |
public function setLines(string $start, ?string $end = null): void
|
|
|
37 |
{
|
|
|
38 |
$this->contextNode->setAttribute('start', $start);
|
|
|
39 |
|
|
|
40 |
if ($end !== null) {
|
|
|
41 |
$this->contextNode->setAttribute('end', $end);
|
|
|
42 |
}
|
|
|
43 |
}
|
|
|
44 |
|
|
|
45 |
public function setTotals(string $executable, string $executed, string $coverage): void
|
|
|
46 |
{
|
|
|
47 |
$this->contextNode->setAttribute('executable', $executable);
|
|
|
48 |
$this->contextNode->setAttribute('executed', $executed);
|
|
|
49 |
$this->contextNode->setAttribute('coverage', $coverage);
|
|
|
50 |
}
|
|
|
51 |
|
|
|
52 |
public function setCrap(string $crap): void
|
|
|
53 |
{
|
|
|
54 |
$this->contextNode->setAttribute('crap', $crap);
|
|
|
55 |
}
|
|
|
56 |
|
|
|
57 |
private function setName(string $name): void
|
|
|
58 |
{
|
|
|
59 |
$this->contextNode->setAttribute('name', $name);
|
|
|
60 |
}
|
|
|
61 |
}
|