blib/lib/Mo/utils/CEFACT.pm

filter: Statementstmt 83.3% 10 / 12 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod n/a totaltotal 87.5% 14 / 16 CC 1 SCAR 0.7
CC
1
Cov
83%
BEGIN
1.3
BEGIN
1.0
BEGIN
1.0
CRAP 1.1
↑ Summary
1 package Mo::utils::CEFACT;
2  
3 2 ▶use base qw(Exporter);
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 0 ▶use CEFACT::Unit;
Subroutine BEGIN: called CC=1 SCAR=2.6
8 use Error::Pure qw(err);
9 use Readonly;
10  
11 Readonly::Array our @EXPORT_OK => qw(check_cefact_unit);
12  
13 our $VERSION = 0.03;
14  
15 sub check_cefact_unit {
16 my ($self, $key) = @_;
17  
18 _check_key($self, $key) && return;
19  
20 if (! CEFACT::Unit->new->check_common_code($self->{$key})) {
21 err "Parameter '$key' must be a UN/CEFACT unit common code.",
22 'Value', $self->{$key},
23 ;
24 }
25  
26 return;
27 }
28  
29 sub _check_key {
30 my ($self, $key) = @_;
31  
32 if (! exists $self->{$key} || ! defined $self->{$key}) {
33 return 1;
34 }
35  
36 return 0;
37 }
38  
39 1;
40  
41 __END__
↑ Summary