LDAP/Role.pm

filter: Statementstmt 70.3% 19 / 27 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 60.0% 6 / 10 Podpod 0.0% 0 / 4 totaltotal 58.1% 25 / 43 CC 2 SCAR 7.8
CC
2
Cov
66%
find_user
6.0
config
2.0
secret
2.0
CRAP 2.2
« LDAP/Role/Command.pm ↑ Summary LDAP/Command/Search.pm »
1 package App::LDAP::Role;
2  
3 13 ▶use Modern::Perl;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 13 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 13 ▶use App::LDAP::Config;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 0 ▶sub config {
Subroutine config: not called CC=1 SCAR=6.9
Pod undocumented
9 0 App::LDAP::Config->instance;
10 }
11  
12 13 ▶use App::LDAP::Secret;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 0 ▶sub secret {
Subroutine secret: not called CC=1 SCAR=6.9
Pod undocumented
14 0 App::LDAP::Secret->instance->secret;
15 }
16  
17 13 ▶use App::LDAP::Connection;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 0 ▶sub ldap {
Subroutine ldap: not called CC=1 SCAR=6.9
Pod undocumented
19 0 App::LDAP::Connection->instance;
20 }
21  
22 0 ▶sub find_user {
Subroutine find_user: not called CC=2 SCAR=17.9
Pod undocumented
23 0 my ( $attr, $value ) = @_;
24 my $search = ldap()->search(
25 base => config()->{nss_base_passwd}->[0],
26 0 scope => config()->{nss_base_passwd}->[1],
27 filter => "$attr=$value",
28 );
29 0 ▶ if ($search->count > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($search->count > 0) { } 0 0 0
30 0 return $search->entry(0);
31 } else {
32 0 die "user $attr=$value not found";
33 }
34 }
35  
36 13 ▶no Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
37  
38 13 1;
39  
40 =pod
41  
42 =head1 NAME
43  
44 App::LDAP::Role - base of all roles in App::LDAP
45  
46 =head1 DESCRIPTION
47  
48 This role provides common helpers for almost all packages in App::LDAP, including ldap() for getting singleton of
49 App::LDAP::Connection, config() for getting singleton of App::LDAP::Config and secret() for getting singleton of
50 App::LDAP::Secret.
51  
52 =cut
53  
« LDAP/Role/Command.pm ↑ Summary LDAP/Command/Search.pm »