| 1 | package Net::LDAP::FilterBuilder; | ||||||||||||||||||||
| 2 | BEGIN { | ||||||||||||||||||||
| 3 | 3 | ▶ | $Net::LDAP::FilterBuilder::VERSION = '1.200000'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | } | ||||||||||||||||||||
| 5 | |||||||||||||||||||||
| 6 | 3 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | 3 | ▶ | use warnings FATAL => 'all'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | 3 | ▶ | use overload '""' => \&as_str; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 10 | |||||||||||||||||||||
| 11 | sub escape { | ||||||||||||||||||||
| 12 | 24 | ▶ | my $class = shift; | ||||||||||||||||||
|
Subroutine
escape: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 13 | 24 | my $value = shift; | |||||||||||||||||||
| 14 | 24 | for ( $value ) { | |||||||||||||||||||
| 15 | 24 | s{\\}{\\}g; | |||||||||||||||||||
| 16 | 24 | s{\*}{\\*}g; | |||||||||||||||||||
| 17 | 24 | s{\(}{\\(}g; | |||||||||||||||||||
| 18 | 24 | s{\)}{\\)}g; | |||||||||||||||||||
| 19 | 24 | s{\0}{\\0}g; | |||||||||||||||||||
| 20 | } | ||||||||||||||||||||
| 21 | 24 | return $value; | |||||||||||||||||||
| 22 | } | ||||||||||||||||||||
| 23 | |||||||||||||||||||||
| 24 | sub new { | ||||||||||||||||||||
| 25 | 31 | ▶ | my $proto = shift; | ||||||||||||||||||
|
Subroutine
new: called CC=9 SCAR=22.0
Pod
undocumented
| |||||||||||||||||||||
| 26 | 31 | ▶ | my $class = ref( $proto ) || $proto; | ||||||||||||||||||
|
Condition66%2/3
ref $proto || $proto
MC/DC0%0/2
ref $proto || $proto
ref $proto
$proto
Truth table66%2/3
A || B
A= ref $protoB= $proto
| |||||||||||||||||||||
| 27 | |||||||||||||||||||||
| 28 | 31 | my $filter; | |||||||||||||||||||
| 29 | |||||||||||||||||||||
| 30 | 31 | ▶ | if ( @_ == 0 ) { | ||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||
| 31 | 0 | $filter = '(objectclass=*)'; | |||||||||||||||||||
| 32 | } | ||||||||||||||||||||
| 33 | elsif ( @_ == 1 ) { | ||||||||||||||||||||
| 34 | 2 | $filter = shift; | |||||||||||||||||||
| 35 | } | ||||||||||||||||||||
| 36 | else { | ||||||||||||||||||||
| 37 | 29 | ▶ | my $op = @_ % 2 ? shift : '='; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 38 | 29 | my @parts; | |||||||||||||||||||
| 39 | 29 | ▶ | while ( my ( $attr, $val ) = splice( @_, 0, 2 ) ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 40 | 30 | ▶ | if ( ref( $val ) eq 'ARRAY' ) { | ||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||
| 41 | 4 | push @parts, sprintf( '(|%s)', join( q{}, map $class->new( $op, $attr, $_ ), @{ $val } ) ); | |||||||||||||||||||
| 42 | } | ||||||||||||||||||||
| 43 | elsif ( ref( $val ) eq 'SCALAR' ) { | ||||||||||||||||||||
| 44 | 2 | push @parts, sprintf( '(%s%s%s)', $attr, $op, ${ $val } ); | |||||||||||||||||||
| 45 | } | ||||||||||||||||||||
| 46 | else { | ||||||||||||||||||||
| 47 | 24 | push @parts, sprintf( '(%s%s%s)', $attr, $op, $class->escape( $val ) ); | |||||||||||||||||||
| 48 | } | ||||||||||||||||||||
| 49 | } | ||||||||||||||||||||
| 50 | 29 | ▶ | if ( @parts > 1 ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 51 | 1 | $filter = sprintf( '(&%s)', join( q{}, @parts ) ); | |||||||||||||||||||
| 52 | } | ||||||||||||||||||||
| 53 | else { | ||||||||||||||||||||
| 54 | 28 | $filter = shift @parts; | |||||||||||||||||||
| 55 | } | ||||||||||||||||||||
| 56 | } | ||||||||||||||||||||
| 57 | |||||||||||||||||||||
| 58 | 31 | bless( \$filter, $class ); | |||||||||||||||||||
| 59 | } | ||||||||||||||||||||
| 60 | |||||||||||||||||||||
| 61 | sub or { | ||||||||||||||||||||
| 62 | 3 | ▶ | my $self = shift; | ||||||||||||||||||
|
Subroutine
or: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 63 | |||||||||||||||||||||
| 64 | 3 | ${ $self } = sprintf( '(|%s%s)', $self, $self->new( @_ ) ); | |||||||||||||||||||
| 65 | |||||||||||||||||||||
| 66 | 3 | return $self; | |||||||||||||||||||
| 67 | } | ||||||||||||||||||||
| 68 | |||||||||||||||||||||
| 69 | sub and { | ||||||||||||||||||||
| 70 | 5 | ▶ | my $self = shift; | ||||||||||||||||||
|
Subroutine
and: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 71 | |||||||||||||||||||||
| 72 | 5 | ${ $self } = sprintf( '(&%s%s)', $self, $self->new( @_ ) ); | |||||||||||||||||||
| 73 | |||||||||||||||||||||
| 74 | 5 | return $self; | |||||||||||||||||||
| 75 | } | ||||||||||||||||||||
| 76 | |||||||||||||||||||||
| 77 | sub not { | ||||||||||||||||||||
| 78 | 2 | ▶ | my $self = shift; | ||||||||||||||||||
|
Subroutine
not: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 79 | |||||||||||||||||||||
| 80 | 2 | ${ $self } = sprintf( '(!%s)', $self ); | |||||||||||||||||||
| 81 | |||||||||||||||||||||
| 82 | 2 | return $self; | |||||||||||||||||||
| 83 | } | ||||||||||||||||||||
| 84 | |||||||||||||||||||||
| 85 | sub as_str { | ||||||||||||||||||||
| 86 | 41 | ▶ | ${ $_[0] }; | ||||||||||||||||||
|
Subroutine
as_str: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 87 | } | ||||||||||||||||||||
| 88 | |||||||||||||||||||||
| 89 | 3 | 1; | |||||||||||||||||||
| 90 | |||||||||||||||||||||
| 91 | # ABSTRACT: Build LDAP filter statements | ||||||||||||||||||||
| 92 | |||||||||||||||||||||
| 93 | |||||||||||||||||||||
| 94 | __END__ | ||||||||||||||||||||