Completed
Push — symfony-console-application ( 3187e2...c3ee2a )
by Luis
10:39
created

StatisticsProcessor   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 55
rs 10
c 0
b 0
f 0
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
B process() 0 31 1
A name() 0 3 1
A __construct() 0 3 1
A getOutputType() 0 3 1
A getInputType() 0 3 1
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