Login.pm

filter: Statementstmt 77.7% 7 / 9 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 3 / 3 Podpod n/a totaltotal 83.3% 10 / 12 CC 1 SCAR 0.9
CC
1
Cov
78%
BEGIN
1.3
BEGIN
1.0
BEGIN
1.0
CRAP 1.1
↑ Summary Login/Role.pm »
1 package Data::Login;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 0 ▶use DateTime;
Subroutine BEGIN: called CC=1 SCAR=2.6
7 use Error::Pure qw(err);
8 use Mo qw(build default is);
9 use Mo::utils 0.28 qw(check_isa check_length check_required);
10 use Mo::utils::Array qw(check_array_object);
11 use Mo::utils::Number qw(check_positive_natural);
12  
13 our $VERSION = 0.05;
14  
15 has hash_type => (
16 is => 'ro',
17 );
18  
19 has id => (
20 is => 'ro',
21 );
22  
23 has login_name => (
24 is => 'ro',
25 );
26  
27 has password_hash => (
28 is => 'ro',
29 );
30  
31 has roles => (
32 default => [],
33 is => 'ro',
34 );
35  
36 has valid_from => (
37 is => 'ro',
38 );
39  
40 has valid_to => (
41 is => 'ro',
42 );
43  
44 sub BUILD {
45 my $self = shift;
46  
47 # Check hash type.
48 check_isa($self, 'hash_type', 'Data::HashType');
49 check_required($self, 'hash_type');
50  
51 # Check id.
52 check_positive_natural($self, 'id');
53  
54 # Check login_name.
55 check_length($self, 'login_name', 50);
56 check_required($self, 'login_name');
57  
58 # Check password_hash.
59 check_length($self, 'password_hash', 128);
60 check_required($self, 'password_hash');
61  
62 # Check roles.
63 check_array_object($self, 'roles', 'Data::Login::Role');
64  
65 # Check valid_from.
66 check_required($self, 'valid_from');
67 check_isa($self, 'valid_from', 'DateTime');
68  
69 # Check valid_to.
70 check_isa($self, 'valid_to', 'DateTime');
71 if (defined $self->{'valid_to'}
72 && DateTime->compare($self->{'valid_from'}, $self->{'valid_to'}) != -1) {
73  
74 err "Parameter 'valid_to' must be older than 'valid_from' parameter.",
75 'Value', $self->{'valid_to'},
76 'Valid from', $self->{'valid_from'},
77 ;
78 }
79  
80 return;
81 }
82  
83 1;
84  
85 __END__
↑ Summary Login/Role.pm »