blib/lib/Math/Histogram.pm

filter: Statementstmt 74.3% 29 / 39 Branchbran 25.0% 1 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 77.7% 7 / 9 Podpod 66.6% 2 / 3 totaltotal 70.9% 39 / 55 SCAR 14.9
CC
4
Cov
70%
deserialize
6.0
_from_hash
3.8
serialize
2.0
CRAP 4.4
↑ Summary blib/lib/Math/Histogram/Axis.pm »
1 package Math::Histogram;
2 7 ▶use 5.008001;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 7 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 7 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 7 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
6 7 ▶use JSON::XS ();
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 7 our $VERSION = '1.03';
9  
10 7 require XSLoader;
11 7 XSLoader::load('Math::Histogram', $VERSION);
12  
13 7 require Math::Histogram::Axis;
14  
15 7 require Exporter;
16 7 our @ISA = qw(Exporter);
17 7 our @EXPORT_OK = qw(
18 make_histogram
19 );
20  
21 7 our %EXPORT_TAGS = (
22 'all' => \@EXPORT_OK,
23 );
24  
25 sub make_histogram {
26 10 ▶ my @axises = map Math::Histogram::Axis->new(@$_), @_;
Subroutine make_histogram: called CC=1 SCAR=0.0
Pod undocumented
27 10 return Math::Histogram->new(\@axises);
28 }
29  
30 sub _from_hash {
31 1 ▶ my ($class, $hashref) = @_;
Subroutine _from_hash: called CC=3 SCAR=13.3
32 1 my $axises_in = $hashref->{axises};
33 1 ▶ if (not ref($axises_in) eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $axises_in eq "ARRAY") 1 0 1
34 1 croak("Need 'axises' hash element as an array reference");
35 }
36 0 my $axises = [];
37 0 push @$axises, Math::Histogram::Axis->_from_hash($_) for @$axises_in;
38 0 return $class->_from_hash_internal($hashref, $axises);
39 }
40  
41 sub serialize {
42 0 ▶ my $self = shift;
Subroutine serialize: not called CC=1 SCAR=6.9
Pod documented
43 0 my $hash = $self->_as_hash;
44 0 return JSON::XS::encode_json($hash);
45 }
46  
47 sub deserialize {
48 0 ▶ my $class = shift;
Subroutine deserialize: not called CC=2 SCAR=17.9
Pod documented
49 0 ▶ my $hash = JSON::XS::decode_json(ref($_[0]) ? ${$_[0]} : $_[0]);
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] ? : 0 0 0
50 0 return $class->_from_hash($hash);
51 }
52  
53 7 1;
54 __END__
↑ Summary blib/lib/Math/Histogram/Axis.pm »