Passed
Push — main ( 1a7f0e...7d39cf )
by Oscar
03:17
created

SvgTrait   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 6
c 1
b 0
f 0
dl 0
loc 24
ccs 4
cts 4
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getElement() 0 3 1
A render() 0 5 1
A __toString() 0 3 1
1
<?php
2
3
/*
4
 * This file is part of ocubom/twig-svg-extension
5
 *
6
 * © Oscar Cubo Medina <https://ocubom.github.io>
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 Ocubom\Twig\Extension\Svg;
13
14
use Ocubom\Twig\Extension\Svg\Util\DomHelper;
15
16
trait SvgTrait
17
{
18
    protected \DOMElement $svg;
19
20 4
    public function getElement(): \DOMElement
21
    {
22 4
        return $this->svg;
23
    }
24
25
    /**
26
     * @deprecated since ocubom/twig-svg-extension 1.1, use __toString instead
27
     *
28
     * @codeCoverageIgnore
29
     */
30
    public function render(): string
31
    {
32
        trigger_deprecation('ocubom/twig-svg-extension', '1.1', 'Using "%s" is deprecated, use "%s::_toString" instead.', __METHOD__, SvgTrait::class);
33
34
        return (string) $this;
35
    }
36
37 2
    public function __toString(): string
38
    {
39 2
        return DomHelper::toXml($this->svg);
40
    }
41
}
42