Passed
Push — parser-refactoring ( e758c6...b54cbd )
by Luis
11:11
created

StatisticsProcessor::process()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 31
Code Lines 22

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 22
nc 1
nop 1
dl 0
loc 31
rs 8.8571
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
12
class StatisticsProcessor extends Processor
13
{
14
    public function name(): string
15
    {
16
        return 'Statistics';
17
    }
18
19
    public function process(Structure $structure): string
20
    {
21
        $summary = new Summary();
22
        $summary->from($structure);
23
24
        // Generate the needed text output
25
        return <<<END
26
Phuml generated statistics
27
==========================
28
29
General statistics
30
------------------
31
32
Classes:    {$summary->classCount()}
33
Interfaces: {$summary->interfaceCount()}
34
35
Attributes: {$summary->attributeCount()} ({$summary->typedAttributeCount()} are typed)
36
    * private:   {$summary->privateAttributeCount()}
37
    * protected: {$summary->protectedAttributeCount()}
38
    * public:    {$summary->publicAttributeCount()}
39
40
Functions:  {$summary->functionCount()} 
41
    * private:   {$summary->privateFunctionCount()}
42
    * protected: {$summary->protectedFunctionCount()}
43
    * public:    {$summary->publicFunctionCount()}
44
45
Average statistics
46
------------------
47
48
Attributes per class: {$summary->attributesPerClass()}
49
Functions per class:  {$summary->functionsPerClass()}
50
51
END;
52
    }
53
}
54