Passed
Push — master ( d09870...716959 )
by Luis
02:38
created

StatisticsProcessor::process()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 6
ccs 4
cts 4
cp 1
crap 1
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 * PHP version 7.1
4
 *
5
 * This source file is subject to the license that is bundled with this package in the file LICENSE.
6
 */
7
namespace PhUml\Processors;
8
9
use PhUml\Code\Structure;
10
use PhUml\Code\Summary;
11
use PhUml\Templates\TemplateEngine;
12
use PhUml\Templates\TemplateFailure;
13
14
/**
15
 * It takes a code `Structure` and extracts a `Summary` of its contents as text
16
 */
17
class StatisticsProcessor extends Processor
18
{
19
    /** @var TemplateEngine */
20
    private $engine;
21
22 15
    public function __construct(TemplateEngine $engine = null)
23
    {
24 15
        $this->engine = $engine ?? new TemplateEngine();
25 15
    }
26
27 6
    public function name(): string
28
    {
29 6
        return 'Statistics';
30
    }
31
32
    /**
33
     * @throws TemplateFailure
34
     */
35 9
    public function process(Structure $structure): string
36
    {
37 9
        $summary = new Summary();
38 9
        $summary->from($structure);
39
40 9
        return $this->engine->render('statistics.txt.twig', ['summary' => $summary]);
41
    }
42
}
43