Completed
Push — master ( 8e1797...9bbc25 )
by Luis
05:11 queued 03:17
created

StatisticsProcessor   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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