API/Role/Common.pm

filter: Statementstmt 59.4% 22 / 37 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 55.5% 5 / 9 Podpod n/a totaltotal 45.7% 27 / 59 CC 6 SCAR 18.7
CC
6
Cov
46%
_build_verbose
12.0
_log
12.0
_handle_server_error
6.0
CRAP 6.5
« API/Role/Iterator.pm ↑ Summary API/Iterator.pm »
1 9 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 9 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 package Net::FreshBooks::API::Role::Common;
5 9 $Net::FreshBooks::API::Role::Common::VERSION = '0.24';
6 9 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 9 ▶use Carp qw( carp croak );
Subroutine BEGIN: called CC=1 SCAR=0.0
8 9 ▶use Data::Dump qw( dump );
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 9 has 'die_on_server_error' => ( is => 'rw', isa => 'Bool', lazy_build => 1, );
11 9 has 'last_server_error' => ( is => 'rw' );
12 9 has 'verbose' => ( is => 'rw', isa => 'Bool', lazy_build => 1 );
13  
14 9 has '_return_xml' => ( is => 'rw', isa => 'Str' );
15 9 has '_request_xml' => ( is => 'rw', isa => 'Str' );
16  
17 0 ▶sub _build_die_on_server_error { return 1; }
Subroutine _build_die_on_server_error: not called CC=1 SCAR=6.9
18  
19 0 ▶sub _build_verbose {
Subroutine _build_verbose: not called CC=3 SCAR=24.8
20 0 ▶ return 1 if $ENV{VERBOSE} || $ENV{DEBUG};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"VERBOSE"} or $ENV{"DEBUG"} 0 0 0
Condition0%0/3
$ENV{"VERBOSE"} or $ENV{"DEBUG"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$ENV{"VERBOSE"} or $ENV{"DEBUG"}
$ENV{"VERBOSE"} $ENV{"DEBUG"}
Truth table0%0/3
A or B
A= $ENV{"VERBOSE"}B= $ENV{"DEBUG"}
ABresult
1X1
011
000
21 0 return 0;
22 }
23  
24 0 ▶sub _handle_server_error {
Subroutine _handle_server_error: not called CC=2 SCAR=17.9
25  
26 0 my $self = shift;
27 0 my $msg = shift;
28  
29 0 ▶ if ( $self->die_on_server_error ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->die_on_server_error) 0 0 0
30 0 croak $msg;
31 }
32  
33 0 $self->last_server_error( $msg );
34  
35 0 return;
36  
37 }
38  
39 0 ▶sub _log { ## no critic
Subroutine _log: not called CC=3 SCAR=24.8
40  
41 0 my $self = shift;
42 0 ▶ return if !$self->verbose;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->verbose 0 0 0
43  
44 0 my ( $level, $message ) = @_;
45 0 ▶ $message .= "\n" if $message !~ m{\n/z}x;
Branch: 1 branch
BranchTrueFalseTotal
unless $message =~ m[\n/z]x 0 0 0
46 0 carp "$level: $message";
47  
48 0 return;
49  
50 }
51  
52 9 1;
53  
54 # ABSTRACT: Roles common to both Base.pm and API.pm
55  
56 __END__
« API/Role/Iterator.pm ↑ Summary API/Iterator.pm »