Profiler::leave()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 7
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 7
loc 7
ccs 0
cts 6
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 2
1
<?php
2
declare(strict_types=1);
3
4
/**
5
 * This file is part of TwigView.
6
 *
7
 ** (c) 2014 Cees-Jan Kiewiet
8
 *
9
 * For the full copyright and license information, please view the LICENSE
10
 * file that was distributed with this source code.
11
 */
12
13
namespace WyriHaximus\TwigView\Lib\Twig\Extension;
14
15
use DebugKit\DebugTimer;
16
use Twig\Extension\ProfilerExtension;
17
use Twig\Profiler\Profile;
18
19
/**
20
 * Class Basic.
21
 * @package WyriHaximus\TwigView\Lib\Twig\Extension
22
 */
23
final class Profiler extends ProfilerExtension
24
{
25
    /**
26
     * Enter $profile.
27
     *
28
     * @param \Twig\Profiler\Profile $profile Profile.
29
     */
30 View Code Duplication
    public function enter(Profile $profile)
31
    {
32
        $name = 'Twig Template: ' . substr($profile->getName(), strlen(ROOT) + 1);
33
        DebugTimer::start($name, __d('twig_view', $name));
34
35
        parent::enter($profile);
36
    }
37
38
    /**
39
     * Leave $profile.
40
     *
41
     * @param \Twig\Profiler\Profile $profile Profile.
42
     */
43 View Code Duplication
    public function leave(Profile $profile)
44
    {
45
        parent::leave($profile);
46
47
        $name = 'Twig Template: ' . substr($profile->getName(), strlen(ROOT) + 1);
48
        DebugTimer::stop($name);
49
    }
50
}
51