File Coverage

lib/Code/Statistics/Metric/sdepth.pm
Criterion Covered Total %
statement 17 17 100.0
branch 2 2 100.0
condition n/a
subroutine 5 5 100.0
pod 1 1 100.0
total 25 25 100.0


line stmt bran cond sub pod time code
1 1     1   694 use strict;
  1         2  
  1         30  
2 1     1   5 use warnings;
  1         1  
  1         57  
3              
4             package Code::Statistics::Metric::sdepth;
5             $Code::Statistics::Metric::sdepth::VERSION = '1.190680';
6             # ABSTRACT: measures the scope depth of a target
7              
8 1     1   6 use Moose;
  1         1  
  1         6  
9             extends 'Code::Statistics::Metric';
10              
11              
12             sub measure {
13 76     76 1 136 my ( $class, $target ) = @_;
14              
15 76         166 my @parent_list = $class->_get_parents( $target );
16              
17 76         135 my $depth = @parent_list - 1;
18              
19 76         317 return $depth;
20             }
21              
22             sub _get_parents {
23 330     330   376 my ( $class, $target ) = @_;
24 330         464 my $parent = $target->parent;
25 330 100       1298 return $target if !$parent;
26 254         395 return ( $target, $class->_get_parents( $parent ) );
27             }
28              
29             1;
30              
31             __END__
32              
33             =pod
34              
35             =encoding UTF-8
36              
37             =head1 NAME
38              
39             Code::Statistics::Metric::sdepth - measures the scope depth of a target
40              
41             =head1 VERSION
42              
43             version 1.190680
44              
45             =head2 measure
46             Returns the scope depth of the given target.
47              
48             =head1 AUTHOR
49              
50             Christian Walde <mithaldu@yahoo.de>
51              
52             =head1 COPYRIGHT AND LICENSE
53              
54              
55             Christian Walde has dedicated the work to the Commons by waiving all of his
56             or her rights to the work worldwide under copyright law and all related or
57             neighboring legal rights he or she had in the work, to the extent allowable by
58             law.
59              
60             Works under CC0 do not require attribution. When citing the work, you should
61             not imply endorsement by the author.
62              
63             =cut