Schema/ResultSet/User.pm

filter: Statementstmt 100% 29 / 29 Branchbran 100% 10 / 10 Conditioncond 100% 6 / 6 MC/DCmcdc 100% 4 / 4 Subroutinesub 100% 7 / 7 Podpod 100% 2 / 2 totaltotal 100% 58 / 58 CC 8 SCAR 12.7
CC
8
Cov
100%
find_user_with_reset_token
6.0
find
3.0
BEGIN
1.0
CRAP 3.6
« Schema/Result/User.pm ↑ Summary Schema/Result/Order.pm »
1 2 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
2  
3 package Interchange6::Schema::ResultSet::User;
4  
5 =head1 NAME
6  
7 Interchange6::Schema::ResultSet::User
8  
9 =cut
10  
11 =head1 SYNOPSIS
12  
13 Provides extra accessor methods for L<Interchange6::Schema::Result::User>
14  
15 =cut
16  
17 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 2 ▶use mro 'c3';
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 2 ▶use parent 'Interchange6::Schema::ResultSet';
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 =head1 METHODS
24  
25 =head2 find
26  
27 Override L<DBIx::Class::ResultSet/find> for lookup of
28 L<Interchange6::Schema::Result::User/username> so that leading/trailing spaces
29 are stripped from username and it is also lower-cased.
30  
31 =cut
32  
33 sub find {
34 29 ▶ my $self = shift;
Subroutine find: called CC=3 SCAR=11.0
Pod documented
35  
36 29 ▶ if ( ref( $_[0] ) eq 'HASH' && defined $_[0]->{username} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_[0] eq "HASH" and defined $_[0]{"username"}) 25 4 29
Condition100%3/3
ref $_[0] eq "HASH" and defined $_[0]{"username"}
!ll&&!rl&&r
2225
MC/DC100%2/2
ref $_[0] eq "HASH" and defined $_[0]{"username"}
ref $_[0] eq "HASH" defined $_[0]{"username"}
Truth table100%3/3
A and B
A= ref $_[0] eq "HASH"B= defined $_[0]{"username"}
ABresult
0X0
100
111
37  
38 # looking for a username
39 25 $_[0]->{username} = lc( $_[0]->{username} );
40 25 $_[0]->{username} =~ s/(^\s+|\s+$)//g;
41 }
42  
43 29 $self->next::method(@_);
44 }
45  
46 =head2 find_user_with_reset_token( $token );
47  
48 Where $token is the combined <Interchange6::Schema::Result::User/reset_token>
49 and <Interchange6::Schema::Result::User/reset_token_checksum> as would be
50 returned by <Interchange6::Schema::Result::User/reset_token_generate>.
51  
52 Returns an <Interchange6::Schema::Result::User> object if $token is found and
53 is valid. On failure returns undef.
54  
55 =cut
56  
57 sub find_user_with_reset_token {
58 10 ▶ my ( $self, $arg ) = @_;
Subroutine find_user_with_reset_token: called CC=6 SCAR=17.9
Pod documented
59  
60 10 ▶ $self->throw_exception("Bad argument to find_user_with_reset_token")
Branch: 1 branch
BranchTrueFalseTotal
unless $arg 1 9 10
61 unless $arg;
62  
63 9 my ( $token, $checksum ) = split(/_/, $arg);
64  
65 9 ▶ $self->throw_exception("Bad argument to find_user_with_reset_token")
Branch: 1 branch
BranchTrueFalseTotal
unless $token and $checksum 4 5 9
Condition100%3/3
$token and $checksum
!ll&&!rl&&r
225
MC/DC100%2/2
$token and $checksum
$token $checksum
Truth table100%3/3
A and B
A= $tokenB= $checksum
ABresult
0X0
100
111
66 unless ( $token && $checksum );
67  
68 5 my $users = $self->search({reset_token => $token});
69  
70 5 ▶ while ( my $user = $users->next ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $user = $users->next) 4 3 7
71 4 ▶ return $user if $user->reset_token_verify( $arg );
Branch: 1 branch
BranchTrueFalseTotal
if $user->reset_token_verify($arg) 2 2 4
72 }
73  
74 3 return undef;
75 }
76  
77 2 1;
« Schema/Result/User.pm ↑ Summary Schema/Result/Order.pm »