Classifier/Result.pm

filter: Statementstmt 69.4% 25 / 36 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 77.7% 7 / 9 Podpod 85.7% 6 / 7 totaltotal 73.0% 38 / 52 CC 3 SCAR 10.4
CC
3
Cov
69%
fqn
6.0
attributes
6.0
BEGIN
1.0
CRAP 2.8
« Classifier.pm ↑ Summary
1 package Data::Classifier::Result;
2  
3 1 our $VERSION = '0.01';
4  
5 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 #private interface
9 3 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
10 3 my ($class, $stack) = @_;
11 3 my $self = {};
12  
13 3 bless($self, $class);
14  
15 3 $self->{STACK} = $stack;
16  
17 3 $self->init;
18  
19 3 return $self;
20 }
21  
22 #this method is intended to be overloaded by subclasses to further customize
23 #the behavior of the classification, such as insctructions to execute at class
24 #boundries
25 3 ▶sub init {
Subroutine init: called CC=1 SCAR=0.0
Pod documented
26 3 return;
27 }
28  
29 #public interface
30  
31 #returns the most specific class node that matched or undef if no
32 #classification was possible
33 5 ▶sub class {
Subroutine class: called CC=1 SCAR=0.0
Pod documented
34 5 my ($self) = @_;
35 5 my @stack = $self->stack;
36 5 my $last = $#stack;
37  
38 5 return $stack[$last];
39 }
40  
41 8 ▶sub stack {
Subroutine stack: called CC=1 SCAR=0.0
Pod documented
42 8 my ($self) = @_;
43  
44 8 return @{$self->{STACK}};
45 }
46  
47 0 ▶sub fqn {
Subroutine fqn: not called CC=2 SCAR=17.9
Pod documented
48 0 my ($self) = @_;
49 0 my $classes = $self->{STACK};
50 0 my @tmp;
51  
52 0 foreach my $class (@$classes) {
53 0 push(@tmp, $class->{name});
54 }
55  
56 0 return join('::', @tmp);
57 }
58  
59 #returns the most specific class name
60 2 ▶sub name {
Subroutine name: called CC=1 SCAR=0.0
Pod documented
61 2 my ($self) = @_;
62 2 my $class = $self->class;
63  
64 2 return $class->{name};
65 }
66  
67 #return a list of data attributes
68 0 ▶sub attributes {
Subroutine attributes: not called CC=2 SCAR=17.9
Pod documented
69 0 my ($self, $attribute) = @_;
70 0 my @ret;
71  
72 0 foreach ($self->stack) {
73 0 push(@ret, $_->{$attribute});
74 }
75  
76 0 return @ret;
77 }
78  
79 1 1;
80  
81 __END__
« Classifier.pm ↑ Summary