blib/lib/Lemonldap/NG/Portal/Register/Base.pm untested

filter: Statementstmt 0.0% 0 / 21 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 28 CC 1 SCAR 6.9
CC
1
Cov
0%
_stripaccents
2.0
applyLoginRule
2.0
BEGIN
2.0
CRAP 2.0
1 # Base package for Register modules
2 package Lemonldap::NG::Portal::Register::Base;
3  
4 use strict;
5 use Mouse;
6 use Text::Unidecode;
7  
8 extends 'Lemonldap::NG::Portal::Main::Plugin';
9  
10 our $VERSION = '2.0.10';
11  
12 sub _stripaccents {
13 my ( $self, $str ) = @_;
14  
15 # UTF8 really shouldn't be decoded here, but in PSGI layer instead
16 utf8::decode($str);
17  
18 # This method replaces all non-ascii characters by the
19 # closest ascii lookalike
20 my $res = unidecode($str);
21 return $res;
22 }
23  
24 sub applyLoginRule {
25 my ( $self, $req ) = @_;
26  
27 my $firstname =
28 lc $self->_stripaccents( $req->data->{registerInfo}->{firstname} );
29 my $lastname =
30 lc $self->_stripaccents( $req->data->{registerInfo}->{lastname} );
31  
32 # For now, get first letter of firstname and lastname
33 my $login = substr( $firstname, 0, 1 ) . $lastname;
34 $login =~ s/\s*//g;
35 return $login;
36 }
37  
38 1;