GX/Callback.pm

filter: Statementstmt 100% 18 / 18 Branchbran 100% 4 / 4 Conditioncond 60.0% 3 / 5 MC/DCmcdc 33.3% 1 / 3 Subroutinesub 100% 6 / 6 Podpod 100% 3 / 3 totaltotal 89.7% 35 / 39 CC 5 SCAR 7.2
CC
5
Cov
93%
new
3.2
arguments
2.0
call
2.0
CRAP 2.1
« GX/Callback/Method.pm ↑ Summary GX/Session/ID/Generator/MD5.pm »
1 # ----------------------------------------------------------------------------------------------------------------------
2 # GX Framework (c) 2009-2011 Jörg A. Uzarek <uzarek@runlevelnull.de>
3 # File: GX/Callback.pm
4 # ----------------------------------------------------------------------------------------------------------------------
5  
6 package GX::Callback;
7  
8 96 ▶use GX::Exception;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10  
11 # ----------------------------------------------------------------------------------------------------------------------
12 # Class setup
13 # ----------------------------------------------------------------------------------------------------------------------
14  
15 96 ▶use GX::Class::Object;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 96 has 'arguments' => (
18 isa => 'Array'
19 );
20  
21 has 'code' => (
22 isa => 'Scalar',
23 106 ▶ constraint => sub { ref eq 'CODE' },
Subroutine __ANON__: called CC=1 SCAR=0.0
24 96 required => 1,
25 accessor => { type => 'get' }
26 );
27  
28 96 build;
29  
30  
31 # ----------------------------------------------------------------------------------------------------------------------
32 # Constructor
33 # ----------------------------------------------------------------------------------------------------------------------
34  
35 154 ▶sub new {
Subroutine new: called CC=3 SCAR=11.7
Pod documented
36  
37 154 ▶ return eval { shift->SUPER::new( ( @_ == 1 ) ? ( code => $_[0] ) : @_ ) } || complain $@;
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 ? : 7 147 154
Condition33%1/3
eval { do { (shift())->SUPER::new(@_ == 1 ? ('code', $_[0]) : @_) } } || &complain($@)
l!l&&r!l&&!r
15400
MC/DC0%0/2
eval { do { (shift())->SUPER::new(@_ == 1 ? ('code', $_[0]) : @_) } } || &complain($@)
eval { do { (shift())->SUPER::new(@_ == 1 ? ('code', $_[0]) : @_) } } &complain($@)
Truth table33%1/3
A || B
A= eval { do { (shift())->SUPER::new(@_ == 1 ? ('code', $_[0]) : @_) } }B= &complain($@)
ABresult
1X1
011
000
38  
39 }
40  
41  
42 # ----------------------------------------------------------------------------------------------------------------------
43 # Public methods
44 # ----------------------------------------------------------------------------------------------------------------------
45  
46 6 ▶sub arguments {
Subroutine arguments: called CC=2 SCAR=6.9
Pod documented
47  
48 6 ▶ return @{ $_[0]->{'arguments'} || return };
Condition100%2/2
$_[0]{'arguments'} || (return)
l!l
24
MC/DC100%1/1
$_[0]{'arguments'} || (return)
$_[0]{'arguments'}
Truth table100%2/2
A
A= $_[0]{'arguments'}
Aresult
11
00
49  
50 }
51  
52 13 ▶sub call {
Subroutine call: called CC=2 SCAR=6.9
Pod documented
53  
54 13 my $self = shift;
55  
56 13 ▶ return $self->{'code'}->( ( $self->{'arguments'} ? @{$self->{'arguments'}} : () ), @_ );
Branch: 1 branch
BranchTrueFalseTotal
$self->{'arguments'} ? : 3 10 13
57  
58 }
59  
60  
61 96 1;
62  
63 __END__
« GX/Callback/Method.pm ↑ Summary GX/Session/ID/Generator/MD5.pm »