blib/lib/OpusVL/AppKit/FormFu/Constraint/AppKitUsername.pm

filter: Statementstmt 100% 18 / 18 Branchbran 50.0% 3 / 6 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 4 / 4 Podpod 100% 2 / 2 totaltotal 84.8% 28 / 33 CC 5 SCAR 13.2
CC
5
Cov
85%
constrain_value
5.4
BEGIN
1.0
BEGIN
1.0
CRAP 3.7
« blib/lib/OpusVL/AppKit/View/SimpleXML.pm ↑ Summary blib/lib/OpusVL/AppKit/LDAPAuth.pm »
1 package OpusVL::AppKit::FormFu::Constraint::AppKitUsername;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use base 'HTML::FormFu::Constraint';
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 5 ▶sub user_stashkey { my $self = shift; my ( $key ) = @_; $self->{user_stashkey} = $key; }
Subroutine user_stashkey: called CC=1 SCAR=0.0
Pod documented
7  
8 sub constrain_value
9 6 ▶{
Subroutine constrain_value: called CC=5 SCAR=16.8
Pod documented
10 6 my $self = shift;
11 6 my ( $value, $params) = @_;
12 6 my $c = $self->form->stash->{context};
13 6 ▶ my $stashkey = $self->{user_stashkey} || 'user';
Condition50%1/2
$self->{'user_stashkey'} || 'user'
l!l
60
MC/DC0%0/1
$self->{'user_stashkey'} || 'user'
$self->{'user_stashkey'}
Truth table50%1/2
A
A= $self->{'user_stashkey'}
Aresult
11
00
14 6 ▶ my $existing = $c->stash->{$stashkey}->id if ( exists $c->stash->{$stashkey} );
Branch: 1 branch
BranchTrueFalseTotal
if exists $c->stash->{$stashkey} 0 6 6
15 6 ▶ my $matched = $c->model('AppKitAuthDB::User')->search( { username => $value, ( $existing ? ( id => { '!=' => $existing } ) : () ) } )->count;
Branch: 1 branch
BranchTrueFalseTotal
$existing ? : 0 6 6
16 6 $self->{message} = "Username already in use";
17 6 ▶ return ( $matched > 0 ) ? 0 : 1;
Branch: 1 branch
BranchTrueFalseTotal
$matched > 0 ? : 0 6 6
18 }
19  
20 ##
21 1 1;
22  
23 __END__
« blib/lib/OpusVL/AppKit/View/SimpleXML.pm ↑ Summary blib/lib/OpusVL/AppKit/LDAPAuth.pm »