SAXReader/DuckHandler.pm

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