lib/IO/Async/XMLStream/SAXReader/DuckHandler.pm

filter: Statementstmt 97.5% 40 / 41 Branchbran 70.0% 7 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 11 / 11 Podpod 0.0% 0 / 2 totaltotal 90.6% 58 / 64 CC 6 SCAR 6.0
CC
6
Cov
92%
AUTOLOAD
3.3
new
2.0
_dyn_method
2.0
CRAP 1.8
« lib/IO/Async/XMLStream/SAXReader.pm ↑ Summary
1 5 ▶use 5.008; # utf8
Subroutine BEGIN: called CC=1 SCAR=0.0
2 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 5 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 package IO::Async::XMLStream::SAXReader::DuckHandler;
7 5 $IO::Async::XMLStream::SAXReader::DuckHandler::VERSION = '0.001000';
8 # ABSTRACT: Deferred Handler proxy for IO::Async constructor-driven interface
9  
10 5 our $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY
11  
12 5 ▶use Scalar::Util qw(weaken);
Subroutine BEGIN: called CC=1 SCAR=0.0
13 5 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24 sub new {
25 2 ▶ my ( $self, $opts ) = @_;
Subroutine new: called CC=2 SCAR=7.0
Pod undocumented
26 2 ▶ croak('SAXReader option is mandatory') unless exists $opts->{SAXReader};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $opts->{"SAXReader"} 0 2 2
27 2 weaken $opts->{SAXReader};
28 2 return bless $opts, $self;
29 }
30  
31 sub _dyn_method {
32 3674 ▶ my ( $self, $method ) = @_;
Subroutine _dyn_method: called CC=2 SCAR=6.9
33 3674 my $sax = $self->{SAXReader};
34 3674 my $event = 'on_' . $method;
35 3674 my $callback = $sax->can_event($event);
36 3674 ▶ return unless $callback;
Branch: 1 branch
BranchTrueFalseTotal
unless $callback 3666 8 3674
37 return sub {
38 3744 ▶ my ( undef, @args ) = @_;
Subroutine __ANON__: called CC=1 SCAR=0.0
39 3744 return $callback->( $sax, @args );
40 8 };
41 }
42  
43 sub can {
44 38 ▶ my ( $self, $method ) = @_;
Subroutine can: called CC=2 SCAR=6.9
Pod undocumented
45 38 my $orig = $self->SUPER::can($method);
46 38 ▶ return $orig if $orig;
Branch: 1 branch
BranchTrueFalseTotal
if $orig 20 18 38
47 18 return $self->_dyn_method($method);
48 }
49  
50 ## no critic (ClassHierarchies::ProhibitAutoloading)
51 sub AUTOLOAD {
52 3656 ▶ my ( $self, @args ) = @_;
Subroutine AUTOLOAD: called CC=3 SCAR=12.0
53 3656 ( my $methname = our $AUTOLOAD ) =~ s/.+:://msx;
54 3656 ▶ return if 'DESTROY' eq $methname;
Branch: 1 branch
BranchTrueFalseTotal
if "DESTROY" eq $methname 0 3656 3656
55 3656 ▶ return unless my $meth = $self->_dyn_method($methname);
Branch: 1 branch
BranchTrueFalseTotal
unless my $meth = $self->_dyn_method($methname) 3656 0 3656
56 0 return $meth->( $self, @args );
57 }
58  
59 5 1;
60  
61 __END__
« lib/IO/Async/XMLStream/SAXReader.pm ↑ Summary