Medley/Package.pm

filter: Statementstmt 88.6% 78 / 88 Branchbran 45.0% 18 / 40 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 15 / 15 Podpod n/a totaltotal 75.6% 112 / 148 CC 23 SCAR 24.4
CC
23
Cov
74%
basename
19.3
basename
13.8
BEGIN
1.1
CRAP 11.5
« Medley/Hostname.pm ↑ Summary Medley/Exec.pm »
1 package Util::Medley::Package;
2 1 $Util::Medley::Package::VERSION = '0.047';
3 1 ▶use Modern::Perl;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Data::Printer alias => 'pdump';
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Kavorka '-all';
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Scalar::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 =head1 NAME
11  
12 Util::Medley::Package - Utility methods for packages.
13  
14 =head1 VERSION
15  
16 version 0.047
17  
18 =cut
19  
20 =head1 SYNOPSIS
21  
22 my $pkg = Util::Medley::Package->new;
23  
24 #
25 # positional
26 #
27 say $pkg->basename('Foo::Bar');
28 say $pkg->basename(Foo::Bar->new);
29  
30 #
31 # named pair
32 #
33 say $pkg->basename(pkg => 'Foo::Bar');
34 say $pkg->basename(pkg => Foo::Bar->new);
35
36 =cut
37  
38 ########################################################
39  
40 =head1 DESCRIPTION
41  
42 A module that provides utility methods for dealing with packages
43  
44 =cut
45  
46 ########################################################
47  
48 =head1 ATTRIBUTES
49  
50 none
51  
52 =head1 METHODS
53  
54 =head2 basename
55  
56 Returns basename for a given string or object. For example, Foo::Bar::Biz
57 yields 'Biz'.
58  
59 =over
60  
61 =item usage:
62  
63 say $pkg->basename('Foo::Bar');
64 say $pkg->basename(Foo::Bar->new);
65  
66 say $pkg->basename(name => 'Foo::Bar');
67 say $pkg->basename(pkg => Foo::Bar->new);
68
69 =item args:
70  
71 =over
72  
73 =item pkg [Str|Object]
74  
75 A string or object.
76  
77 =back
78  
79 =back
80
81 =cut
82  
83 1 ▶multi method basename (Str|Object :$pkg!) {
Subroutine BEGIN: called CC=1 SCAR=0.3
Subroutine BEGIN: called CC=1 SCAR=0.3
Subroutine BEGIN: called CC=1 SCAR=0.3
Subroutine BEGIN: called CC=1 SCAR=0.3
Subroutine BEGIN: called CC=1 SCAR=0.3
Subroutine basename: called CC=15 SCAR=29.6
Branch: 11 branches
BranchTrueFalseTotal
ref $_[0] eq 'Kavorka::Signature::NOBBLE' ? : 2 0 2
@_ ? : 2 0 2
unless ($____nobble_checks) 0 2 2
if ($#_ == 0 and ref $_[0] eq 'HASH') { } 0 2 2
if ($slice_length % 2 != 0) 0 2 2
if ($i <= $#_) 2 2 4
$OK{$_} or Carp::croak("Unknown named parameter: $_") 0 2 2
exists $_{'pkg'} ? : 2 0 2
unless ($____nobble_checks) 0 2 2
if (exists $_{"pkg"}) 0 0 0
Type::Tiny::XS::AUTO::TC1($pkg) or _failed_check(45, "Str|Object", $pkg, "exception_class", "Error::TypeTiny::Assertion") 0 0 0
Condition33%1/3
$#_ == 0 and ref $_[0] eq "HASH"
!ll&&!rl&&r
200
MC/DC0%0/2
$#_ == 0 and ref $_[0] eq "HASH"
$#_ == 0 ref $_[0] eq "HASH"
Truth table33%1/3
A and B
A= $#_ == 0B= ref $_[0] eq "HASH"
ABresult
0X0
100
111
84  
85 2 my $name;
86 2 ▶ if (Scalar::Util::blessed($pkg)) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($pkg)) { } 1 1 2
87 1 $name = ref($pkg);
88 }
89 else {
90 1 $name = $pkg;
91 }
92
93 2 my @a = split( /::/, $name );
94 2 return pop @a;
95 }
96  
97 1 ▶multi method basename (Str|Object $pkg) {
Subroutine BEGIN: called CC=1 SCAR=0.6
Subroutine BEGIN: called CC=1 SCAR=0.6
Subroutine basename: called CC=9 SCAR=26.2
Branch: 8 branches
BranchTrueFalseTotal
ref $_[0] eq 'Kavorka::Signature::NOBBLE' ? : 2 0 2
@_ ? : 2 0 2
unless ($____nobble_checks) 0 2 2
if @_ != 1 0 2 2
$#_ >= 0 ? : 2 0 2
unless ($____nobble_checks) 0 2 2
if ($#_ >= 0) 0 0 0
Type::Tiny::XS::AUTO::TC1($pkg) or _failed_check(46, "Str|Object", $pkg, "exception_class", "Error::TypeTiny::Assertion") 0 0 0
98  
99 2 return $self->basename(pkg => $pkg);
100 }
101  
102 1 1;
« Medley/Hostname.pm ↑ Summary Medley/Exec.pm »