blib/lib/BLOB.pm

filter: Statementstmt 84.3% 27 / 32 Branchbran 62.5% 5 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 87.5% 7 / 8 Podpod 100% 3 / 3 totaltotal 82.3% 42 / 51 CC 4 SCAR 6.0
CC
4
Cov
80%
is_blob
3.2
mark
2.2
__ANON__
1.1
CRAP 1.8
↑ Summary
1 package BLOB;
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use Carp qw(carp);
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use Exporter ();
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 # No "our" in Perl 5.0
7 1 ▶use vars qw(@ISA $VERSION @EXPORT);
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 1 $VERSION = '1.01';
10 1 @ISA = qw(Exporter);
11 1 @EXPORT = qw(mark_blob is_blob);
12  
13 # Fallback for Perl < 5.8
14 0 ▶*utf8::downgrade = sub { 1 } if not defined &utf8::downgrade;
Subroutine __ANON__: not called CC=1 SCAR=1.2
Branch: 1 branch
BranchTrueFalseTotal
unless defined &utf8::downgrade 0 1 1
15  
16 # Class method
17 2 ▶sub mark {
Subroutine mark: called CC=2 SCAR=7.9
Pod documented
18 2 my $class = shift;
19 2 my $blob_ref = \shift;
20 2 ▶ if (not utf8::downgrade($$blob_ref, 1)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (utf8::downgrade($$blob_ref, 1)) 0 2 2
21 0 carp "Wide character outside byte range in BLOB, encoding data with UTF-8";
22 0 utf8::encode($$blob_ref);
23 }
24 2 bless $blob_ref, $class;
25 }
26  
27 # Function
28 1 ▶sub mark_blob {
Subroutine mark_blob: called CC=1 SCAR=0.0
Pod documented
29 1 BLOB->mark($_[0]);
30 }
31  
32 # Function
33 6 ▶sub is_blob {
Subroutine is_blob: called CC=3 SCAR=11.6
Pod documented
34 6 my $blob_ref = \shift;
35 6 ▶ return undef if not eval { $blob_ref->isa('BLOB') };
Branch: 1 branch
BranchTrueFalseTotal
unless eval { do { $blob_ref->isa("BLOB") } } 4 2 6
36 2 ▶ if (not utf8::downgrade($$blob_ref, 1)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (utf8::downgrade($$blob_ref, 1)) 0 2 2
37 0 carp "Wide character outside byte range in BLOB, encoding data with UTF-8";
38 0 utf8::encode($$blob_ref);
39 }
40 2 return 1;
41 }
42  
43 1 1;
44  
45 __END__
↑ Summary