blib/lib/IO/Barf.pm

filter: Statementstmt 100% 33 / 33 Branchbran 80.0% 8 / 10 Conditioncond 100% 3 / 3 MC/DCmcdc 100% 2 / 2 Subroutinesub 100% 7 / 7 Podpod 100% 1 / 1 totaltotal 96.4% 54 / 56 SCAR 19.5
CC
7
Cov
96%
barf
7.0
BEGIN
1.0
BEGIN
1.0
CRAP 7.0
↑ Summary
1 package IO::Barf;
2  
3 3 ▶use base qw(Exporter);
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 3 ▶use Error::Pure qw(err);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 ▶use Readonly;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 3 ▶use Scalar::Util qw(blessed);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 # Constants.
12 3 Readonly::Array our @EXPORT => qw(barf);
13  
14 3 our $VERSION = 0.10;
15  
16 # Barf content to file.
17 sub barf {
18 12 ▶ my ($file_or_handler, $content) = @_;
Subroutine barf: called CC=7 SCAR=19.5
Pod documented
19  
20 # File.
21 12 my $ref = ref $file_or_handler;
22 12 ▶ if (! $ref) {
Branch: 3 branches
BranchTrueFalseTotal
if (not $ref) { } 4 8 12
elsif ($ref eq 'GLOB') { } 3 5 8
elsif (builtin::blessed($file_or_handler) and $file_or_handler->isa('IO::Handle')) { } 3 2 5
23 4 ▶ open my $ouf, '>', $file_or_handler
Branch: 1 branch
BranchTrueFalseTotal
open my $ouf, ">", $file_or_handler or err("Cannot open file '${file_or_handler}'.") 0 4 4
24 or err "Cannot open file '$file_or_handler'.";
25 4 print {$ouf} $content;
26 4 ▶ close $ouf or err "Cannot close file '$file_or_handler'.";
Branch: 1 branch
BranchTrueFalseTotal
close $ouf or err("Cannot close file '${file_or_handler}'.") 0 4 4
27  
28 # Handler
29 } elsif ($ref eq 'GLOB') {
30 3 print {$file_or_handler} $content;
31  
32 # IO::Handle.
33 ▶ } elsif (blessed($file_or_handler)
Condition100%3/3
builtin::blessed($file_or_handler) and $file_or_handler->isa("IO::Handle")
!ll&&!rl&&r
113
MC/DC100%2/2
builtin::blessed($file_or_handler) and $file_or_handler->isa("IO::Handle")
builtin::blessed($file_or_handler) $file_or_handler->isa("IO::Handle")
Truth table100%3/3
A and B
A= builtin::blessed($file_or_handler)B= $file_or_handler->isa("IO::Handle")
ABresult
0X0
100
111
34 && $file_or_handler->isa('IO::Handle')) {
35  
36 3 $file_or_handler->print($content);
37  
38 # Other.
39 } else {
40 2 err "Unsupported reference '$ref'.";
41 }
42  
43 10 return;
44 }
45  
46 3 1;
47  
48 __END__
↑ Summary