blib/lib/like.pm

filter: Statementstmt 100% 19 / 19 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod n/a totaltotal 96.0% 24 / 25 CC 3 SCAR 6.9
CC
3
Cov
95%
import
3.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.0
↑ Summary
1 package like;
2  
3 2 ▶use latest;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 2 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 =head1 NAME
8  
9 like - Declare support for an interface
10  
11 =head1 VERSION
12  
13 This document describes like version 0.02
14  
15 =cut
16  
17 2 our $VERSION = '0.02';
18  
19 =head1 SYNOPSIS
20  
21 package MyThing;
22  
23 use like qw( some::interface );
24  
25 # later
26  
27 if ( MyThing->isa( 'some::interface' ) ) {
28 print "Yes it is!\n";
29 }
30
31 =head1 DESCRIPTION
32  
33 Allows a package to declare that it ISA named interface without that
34 interface having to pre-exist.
35  
36 This
37  
38 package MyThing;
39  
40 use like qw( some::interface );
41  
42 is equivalent to
43  
44 package some::interface; # make the package exist
45  
46 package MyThing;
47  
48 use vars qw( @ISA );
49 push @ISA, 'some::interface';
50  
51 The like declaration is intended to declare that your package
52 conforms to some interface without needing to have the consumer of that
53 interface installed.
54  
55 There is no test that your package really does conform to any interface
56 (see L<Moose>); you're just declaring your intent.
57  
58 =cut
59  
60 3 ▶sub import {
Subroutine import: called CC=3 SCAR=11.0
61 3 my ( $class, @isa ) = @_;
62 3 my $caller = caller;
63 2 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
64 3 for my $isa ( @isa ) {
65 3 ▶ @{"${isa}::ISA"} = () unless @{"${isa}::ISA"};
Branch: 1 branch
BranchTrueFalseTotal
unless @{"${isa}::ISA";} 3 0 3
66 }
67 3 push @{"${caller}::ISA"}, @isa;
68 }
69  
70 2 1;
71 __END__
↑ Summary