Completed
Push — symfony-console-application ( 3187e2...c3ee2a )
by Luis
10:39
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\Summary;
10
use plProcessorOptions;
11
12
class StatisticsProcessor extends Processor
13
{
14
    public $options;
15
16
    public function __construct()
17
    {
18
        $this->options = new plProcessorOptions();
19
    }
20
21
    public function name(): string
22
    {
23
        return 'Statistics';
24
    }
25
26
    public function getInputType(): string
27
    {
28
        return 'application/phuml-structure';
29
    }
30
31
    public function getOutputType(): string
32
    {
33
        return 'text/plain';
34
    }
35
36
    public function process($structure)
37
    {
38
        $summary = new Summary();
39
        $summary->from($structure);
40
41
        // Generate the needed text output
42
        return <<<END
43
Phuml generated statistics
44
==========================
45
46
General statistics
47
------------------
48
49
Classes:    {$summary->classCount()}
50
Interfaces: {$summary->interfaceCount()}
51
52
Attributes: {$summary->attributeCount()} ({$summary->typedAttributeCount()} are typed)
53
    * private:   {$summary->privateAttributeCount()}
54
    * protected: {$summary->protectedAttributeCount()}
55
    * public:    {$summary->publicAttributeCount()}
56
57
Functions:  {$summary->functionCount()} 
58
    * private:   {$summary->privateFunctionCount()}
59
    * protected: {$summary->protectedFunctionCount()}
60
    * public:    {$summary->publicFunctionCount()}
61
62
Average statistics
63
------------------
64
65
Attributes per class: {$summary->attributesPerClass()}
66
Functions per class:  {$summary->functionsPerClass()}
67
68
END;
69
    }
70
}
71