File Coverage

File:lib/Code/Statistics/Metric/sdepth.pm
Coverage:100.0%

linestmtbrancondsubpodtimecode
1
2
2
2
0
0
0
use strict;
2
2
2
2
0
0
0
use warnings;
3
4package Code::Statistics::Metric::sdepth;
5
6# ABSTRACT: measures the scope depth of a target
7
8
2
2
2
0
0
0
use Moose;
9extends 'Code::Statistics::Metric';
10
11 - 13
=head2 measure
    Returns the scope depth of the given target.
=cut
14
15sub measure {
16    my ( $class, $target ) = @_;
17
18    my @parent_list = $class->_get_parents( $target );
19
20    my $depth = @parent_list - 1;
21
22    return $depth;
23}
24
25sub _get_parents {
26    my ( $class, $target ) = @_;
27    my $parent = $target->parent;
28    return $target if !$parent;
29    return ( $target, $class->_get_parents( $parent ) );
30}
31
321;