Analizo/Metric/ResponseForClass.pm

filter: Statementstmt 100% 23 / 23 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 33.3% 1 / 3 totaltotal 93.7% 30 / 32 CC 2 SCAR 2.5
CC
2
Cov
100%
_number_of_functions_called_by
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.3
« Analizo/Metric/DepthOfInheritanceTree.pm ↑ Summary Analizo/Batch.pm »
1 package Analizo::Metric::ResponseForClass;
2 21 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 21 ▶use parent qw(Class::Accessor::Fast Analizo::ModuleMetric);
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 =head1 NAME
6  
7 Analizo::Metric::ResponseForClass - Response for Class (RFC) metric
8  
9 =head1 DESCRIPTION
10  
11 The metric calculation is based on the following article and calculates the sum
12 between the number of methods in the module and the number of functions called
13 by each module function.
14  
15 Article: I<A metrics suite for object oriented design> by Shyam R. Chidamber
16 and Chris F. Kemerer.
17  
18 See the paragraph about Response for Class in the article:
19  
20 ... The response set of a class is a set of methods that can potentially be
21 executed in response to a message received by an object of that class. The
22 cardinality of this set is a measure of the attributes of objects in the class.
23 Since it specifically includes methods called from outside the class, it is
24 also a measure of the potential communication between the class and other
25 classes.
26  
27 =cut
28  
29 21 __PACKAGE__->mk_accessors(qw( model ));
30  
31 15 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
32 15 my ($package, %args) = @_;
33 my @instance_variables = (
34 model => $args{model}
35 15 );
36 15 return bless { @instance_variables }, $package;
37 }
38  
39 4 ▶sub description {
Subroutine description: called CC=1 SCAR=0.0
Pod undocumented
40 4 return "Response for a Class";
41 }
42  
43 12 ▶sub calculate {
Subroutine calculate: called CC=1 SCAR=0.0
Pod undocumented
44 12 my ($self, $module) = @_;
45  
46 12 my @functions = $self->model->functions($module);
47 12 my $number_of_functions = scalar @functions;
48 12 my $number_of_functions_called_by_module_functions = $self->_number_of_functions_called_by(@functions);
49  
50 12 return $number_of_functions + $number_of_functions_called_by_module_functions;
51 }
52  
53 12 ▶sub _number_of_functions_called_by {
Subroutine _number_of_functions_called_by: called CC=2 SCAR=6.9
54 12 my ($self, @functions) = @_;
55  
56 12 my $count = 0;
57 12 for my $function (@functions){
58 18 $count += scalar keys(%{$self->model->calls->{$function}});
59 }
60 12 return $count;
61 }
62  
63 21 1;
64  
« Analizo/Metric/DepthOfInheritanceTree.pm ↑ Summary Analizo/Batch.pm »