Access/Resource.pm

filter: Statementstmt 81.0% 30 / 37 Branchbran 37.5% 3 / 8 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 80.0% 8 / 10 Podpod 83.3% 5 / 6 totaltotal 69.7% 46 / 66 CC 6 SCAR 14.2
CC
6
Cov
69%
is_authorized
12.0
deauthorize
6.0
authorized
2.1
CRAP 4.2
« Access/Group.pm ↑ Summary
1 package SVN::Access::Resource;
2  
3 1 ▶use 5.006001;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 ▶use Tie::IxHash;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 1 our $VERSION = '0.10';
10  
11 sub new {
12 28 ▶ my ($class, %attr) = @_;
Subroutine new: called CC=1 SCAR=0.0
Pod documented
13  
14 # keep our hashes in order. Thanks Kage of HackThisSite.org
15 28 my (%authorized, $t);
16 28 $t = tie(%authorized, 'Tie::IxHash');
17
18 # make sure we copy in stuff that was passed.
19 28 %authorized = (@{$attr{authorized}});
20
21 28 $attr{authorized} = \%authorized;
22 28 $attr{_authorized_tie} = $t;
23
24 28 return bless(\%attr, $class);
25 }
26  
27 sub authorized {
28 90 ▶ my ($self) = @_;
Subroutine authorized: called CC=2 SCAR=7.6
Pod documented
29 90 ▶ if (ref ($self->{authorized}) eq "HASH") {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self->{"authorized"} eq "HASH") 90 0 90
30 90 return $self->{authorized};
31 }
32 0 return undef;
33 }
34  
35 sub is_authorized {
36 0 ▶ my ($self, $entity) = @_;
Subroutine is_authorized: not called CC=3 SCAR=24.8
Pod undocumented
37 0 ▶ if (defined($self->{authorized}) && exists($self->{authorized}->{$entity})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"authorized"} and exists $self->{"authorized"}{$entity}) 0 0 0
Condition0%0/3
defined $self->{"authorized"} and exists $self->{"authorized"}{$entity}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self->{"authorized"} and exists $self->{"authorized"}{$entity}
defined $self->{"authorized"} exists $self->{"authorized"}{$entity}
Truth table0%0/3
A and B
A= defined $self->{"authorized"}B= exists $self->{"authorized"}{$entity}
ABresult
0X0
100
111
38 0 return 1;
39 }
40 0 return undef;
41 }
42  
43 sub authorize {
44 38 ▶ my ($self, @rest) = @_;
Subroutine authorize: called CC=2 SCAR=6.9
Pod documented
45  
46 38 ▶ if ($rest[$#rest] =~ /^\d+$/o) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rest[$#rest] =~ /^\d+$/o) { } 1 37 38
47 1 $self->{_authorized_tie}->Splice($rest[$#rest], 0, @rest[0..$#rest - 1]);
48 } else {
49 37 $self->{_authorized_tie}->Push(@rest);
50 }
51 }
52  
53 sub deauthorize {
54 0 ▶ my ($self, $entity) = @_;
Subroutine deauthorize: not called CC=2 SCAR=17.9
Pod documented
55 0 ▶ delete ($self->{authorized}->{$entity}) if ref($self->{authorized});
Branch: 1 branch
BranchTrueFalseTotal
if ref $self->{"authorized"} 0 0 0
56 }
57  
58 sub name {
59 236 ▶ my ($self) = @_;
Subroutine name: called CC=1 SCAR=0.0
Pod documented
60 236 return $self->{name};
61 }
62  
63 1 1;
64 __END__
« Access/Group.pm ↑ Summary