| 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
Condition0%0/3
$ENV{"VERBOSE"} or $ENV{"DEBUG"}
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"}
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 0 | my ( $level, $message ) = @_; | |||||||||||||||||||||||||||
| 45 | 0 | ▶ | $message .= "\n" if $message !~ m{\n/z}x; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||