blib/lib/PHP/MySource/Session.pm

filter: Statementstmt 47.3% 36 / 76 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 20 MC/DCmcdc 0.0% 0 / 12 Subroutinesub 47.6% 10 / 21 Podpod 0.0% 0 / 3 totaltotal 32.8% 46 / 140 CC 13 SCAR 32.7
CC
13
Cov
35%
AUTOLOAD
77.0
new
30.0
dump
2.0
CRAP 26.3
↑ Summary
1 package PHP::MySource::Session;
2 1 $VERSION = 0.03;
3  
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use vars qw( $AUTOLOAD );
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use PHP::Session;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 sub new
12 0 ▶{
Subroutine new: not called CC=5 SCAR=34.0
Pod undocumented
13 0 my ($class, %args) = @_;
14  
15 bless
16 { _mysource_root => $args{'mysource_root'} || croak('You must supply your MySource installation directory.'),
17 _mysource_cache => $args{'mysource_cache'} || $args{'mysource_root'} . '/cache',
18 _session_id => $args{'session_id'} || croak('You must supply a MySource session id.'),
19 0 ▶ _session_obj => new PHP::Session($args{'session_id'}, {save_path=>$args{'mysource_cache'} || $args{'mysource_root'} . '/cache'})
Condition0%0/8
$args{'mysource_root'} || croak('You must supply your MySource installation directory.')
l!l
00
$args{'mysource_cache'} || $args{'mysource_root'} . '/cache'
l!l
00
$args{'session_id'} || croak('You must supply a MySource session id.')
l!l
00
$args{'mysource_cache'} || $args{'mysource_root'} . '/cache'
l!l
00
MC/DC0%0/1
$args{'mysource_root'} || croak('You must supply your MySource installation directory.')
$args{'mysource_root'}
MC/DC0%0/1
$args{'mysource_cache'} || $args{'mysource_root'} . '/cache'
$args{'mysource_cache'}
MC/DC0%0/1
$args{'session_id'} || croak('You must supply a MySource session id.')
$args{'session_id'}
MC/DC0%0/1
$args{'mysource_cache'} || $args{'mysource_root'} . '/cache'
$args{'mysource_cache'}
Truth table0%0/2
A
A= $args{'mysource_root'}
Aresult
11
00
Truth table0%0/2
A
A= $args{'mysource_cache'}
Aresult
11
00
Truth table0%0/2
A
A= $args{'session_id'}
Aresult
11
00
Truth table0%0/2
A
A= $args{'mysource_cache'}
Aresult
11
00
20 }, $class;
21 }
22  
23 {
24  
25 1 my %_attrs =
26 ( _mysource_root => 'read',
27 _mysource_cache => 'read',
28 _session_id => 'read'
29 );
30  
31 sub _accessible
32 0 ▶ {
Subroutine _accessible: not called CC=1 SCAR=0.6
33 0 my ($self, $attr, $mode) = @_;
34 1 ▶ no warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
35 0 $_attrs{$attr} =~ /$mode/;
36 1 ▶ use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
37 }
38 }
39  
40 {
41 1 my %_parent_attrs =
42 (
43 registered_name => 'read',
44 editor_pages => 'read',
45 print_errors => 'read',
46 result_message => 'read',
47 user => 'read',
48 external_vars => 'read',
49 error_call => 'read',
50 login_attempts => 'read',
51 access_groups => 'read',
52 error_msg => 'read',
53 login_key => 'read',
54 last_access => 'read'
55 );
56  
57 sub _parent_accessible
58 0 ▶ {
Subroutine _parent_accessible: not called CC=1 SCAR=0.6
59 0 my ($self, $attr, $mode) = @_;
60 1 ▶ no warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
61 0 $_parent_attrs{$attr} =~ /$mode/;
62 1 ▶ use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
63 }
64 }
65  
66 sub is_logged_in
67 1 ▶{
Subroutine is_logged_in: not called CC=1 SCAR=2.6
Pod undocumented
68 0 my $self = shift;
69  
70 0 $self->{'_session_obj'}->{'_data'}->{'SESSION'}->{'user'};
71 }
72  
73 # Just dump out all of the Session variables
74 sub dump
75 0 ▶{
Subroutine dump: not called CC=1 SCAR=6.9
Pod undocumented
76 0 my $self = shift;
77  
78 0 Dumper($self->{'_session_obj'}->{'_data'}->{'SESSION'});
79 }
80  
81 sub AUTOLOAD
82 0 ▶{
Subroutine AUTOLOAD: not called CC=9 SCAR=43.4
83 1 ▶ no strict "refs";
Subroutine BEGIN: called CC=1 SCAR=0.0
84 0 my ($self, $newval) = @_;
85  
86 # was a get method called?
87 0 ▶ if ($AUTOLOAD =~ /.*::get(_\w+)/ && $self->_accessible($1, 'read'))
Branch: 1 branch
BranchTrueFalseTotal
if ($PHP::MySource::Session::AUTOLOAD =~ /.*::get(_\w+)/ and $self->_accessible($1, "read")) 0 0 0
Condition0%0/3
$PHP::MySource::Session::AUTOLOAD =~ /.*::get(_\w+)/ and $self->_accessible($1, "read")
!ll&&!rl&&r
000
MC/DC0%0/2
$PHP::MySource::Session::AUTOLOAD =~ /.*::get(_\w+)/ and $self->_accessible($1, "read")
$PHP::MySource::Session::AUTOLOAD =~ /.*::get(_\w+)/ $self->_accessible($1, "read")
Truth table0%0/3
A and B
A= $PHP::MySource::Session::AUTOLOAD =~ /.*::get(_\w+)/B= $self->_accessible($1, "read")
ABresult
0X0
100
111
88 {
89 0 my $attr_name = $1;
90 0 ▶ *{$AUTOLOAD} = sub { return $_[0]->{$attr_name} };
Subroutine __ANON__: not called CC=1 SCAR=6.9
91 0 return $self->{$attr_name};
92 }
93  
94 # was a set method called?
95 0 ▶ if ($AUTOLOAD =~ /.*::set(_\w+)/ && $self->_accessible($1, 'write'))
Branch: 1 branch
BranchTrueFalseTotal
if ($PHP::MySource::Session::AUTOLOAD =~ /.*::set(_\w+)/ and $self->_accessible($1, "write")) 0 0 0
Condition0%0/3
$PHP::MySource::Session::AUTOLOAD =~ /.*::set(_\w+)/ and $self->_accessible($1, "write")
!ll&&!rl&&r
000
MC/DC0%0/2
$PHP::MySource::Session::AUTOLOAD =~ /.*::set(_\w+)/ and $self->_accessible($1, "write")
$PHP::MySource::Session::AUTOLOAD =~ /.*::set(_\w+)/ $self->_accessible($1, "write")
Truth table0%0/3
A and B
A= $PHP::MySource::Session::AUTOLOAD =~ /.*::set(_\w+)/B= $self->_accessible($1, "write")
ABresult
0X0
100
111
96 {
97 0 my $attr_name = $1;
98 0 ▶ *{$AUTOLOAD} = sub { $_[0]->{$attr_name} = $_[1]; return };
Subroutine __ANON__: not called CC=1 SCAR=6.9
99 0 $self->{$1} = $newval;
100 return
101 0 }
102  
103 # was a get method called on the parent obj?
104 0 ▶ if ($AUTOLOAD =~ /.*::get_(\w+)/ && $self->_parent_accessible($1, 'read'))
Branch: 1 branch
BranchTrueFalseTotal
if ($PHP::MySource::Session::AUTOLOAD =~ /.*::get_(\w+)/ and $self->_parent_accessible($1, "read")) 0 0 0
Condition0%0/3
$PHP::MySource::Session::AUTOLOAD =~ /.*::get_(\w+)/ and $self->_parent_accessible($1, "read")
!ll&&!rl&&r
000
MC/DC0%0/2
$PHP::MySource::Session::AUTOLOAD =~ /.*::get_(\w+)/ and $self->_parent_accessible($1, "read")
$PHP::MySource::Session::AUTOLOAD =~ /.*::get_(\w+)/ $self->_parent_accessible($1, "read")
Truth table0%0/3
A and B
A= $PHP::MySource::Session::AUTOLOAD =~ /.*::get_(\w+)/B= $self->_parent_accessible($1, "read")
ABresult
0X0
100
111
105 {
106 0 my $attr_name = $1;
107 #print $self->{'_session_obj'}->{"_data"}->{'SESSION'}->{$attr_name};
108 0 ▶ *{$AUTOLOAD} = sub { return $_[0]->{'_session_obj'}->{'_data'}->{'SESSION'}->{$attr_name} };
Subroutine __ANON__: not called CC=1 SCAR=6.9
109 0 return $self->{'_session_obj'}->{'_data'}->{'SESSION'}->{$attr_name};
110 }
111  
112 # was a set method called on the parent obj?
113 0 ▶ if ($AUTOLOAD =~ /.*::set_(\w+)/ && $self->_parent_accessible($1, 'write'))
Branch: 1 branch
BranchTrueFalseTotal
if ($PHP::MySource::Session::AUTOLOAD =~ /.*::set_(\w+)/ and $self->_parent_accessible($1, "write")) 0 0 0
Condition0%0/3
$PHP::MySource::Session::AUTOLOAD =~ /.*::set_(\w+)/ and $self->_parent_accessible($1, "write")
!ll&&!rl&&r
000
MC/DC0%0/2
$PHP::MySource::Session::AUTOLOAD =~ /.*::set_(\w+)/ and $self->_parent_accessible($1, "write")
$PHP::MySource::Session::AUTOLOAD =~ /.*::set_(\w+)/ $self->_parent_accessible($1, "write")
Truth table0%0/3
A and B
A= $PHP::MySource::Session::AUTOLOAD =~ /.*::set_(\w+)/B= $self->_parent_accessible($1, "write")
ABresult
0X0
100
111
114 {
115 0 my $attr_name = $1;
116 0 ▶ *{$AUTOLOAD} = sub { $_[0]->{'_session_obj'}->{'_data'}->{'SESSION'}->{$attr_name} = $_[1]; return };
Subroutine __ANON__: not called CC=1 SCAR=6.9
117 0 $self->{'_session_obj'}->{'_data'}->{'SESSION'}->{$1} = $newval;
118 return
119 0 }
120  
121 0 croak ("No such method: $AUTOLOAD");
122  
123 }
124  
125 sub DESTROY
126 0 ▶{
Subroutine DESTROY: not called CC=1 SCAR=0.0
127 # nothing to do but make AUTOLOAD happy
128 }
129  
130 1 1;
131 __END__
↑ Summary