Traits.pm

filter: Statementstmt 96.8% 31 / 32 Branchbran 90.0% 9 / 10 Conditioncond 80.0% 4 / 5 MC/DCmcdc 66.6% 2 / 3 Subroutinesub 100% 8 / 8 Podpod 100% 2 / 2 totaltotal 93.3% 56 / 60 CC 8 SCAR 12.0
CC
8
Cov
94%
new_with_traits
6.0
BEGIN
2.5
with_traits
2.0
CRAP 3.3
« Traits/Util.pm ↑ Summary
1 8 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 8 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 8 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 0 ▶BEGIN { if ($] < 5.010000) { require UNIVERSAL::DOES } };
Subroutine BEGIN: called CC=2 SCAR=9.2
Branch: 1 branch
BranchTrueFalseTotal
if ($] < "5.01") 0 8 8
6  
7 package MooX::Traits;
8  
9 8 our $AUTHORITY = 'cpan:TOBYINK';
10 8 our $VERSION = '0.005';
11  
12 8 ▶use Role::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 sub _trait_namespace
15 17 ▶{
Subroutine _trait_namespace: called CC=1 SCAR=0.0
16 17 ();
17 }
18  
19 sub with_traits
20 34 ▶{
Subroutine with_traits: called CC=2 SCAR=6.9
Pod documented
21 34 my $class = shift;
22 34 ▶ return $class unless @_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 8 26 34
23
24 26 require MooX::Traits::Util;
25 26 MooX::Traits::Util::new_class_with_traits($class, @_);
26 }
27  
28 sub new_with_traits
29 23 ▶{
Subroutine new_with_traits: called CC=6 SCAR=17.9
Pod documented
30 23 my $class = shift;
31 23 my (%args, $pass_as_ref);
32 23 ▶ if (@_==1 and ref($_[0]) eq 'HASH')
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 1 and ref $_[0] eq 'HASH') { } 1 22 23
Condition66%2/3
@_ == 1 and ref $_[0] eq "HASH"
!ll&&!rl&&r
2201
MC/DC50%1/2
@_ == 1 and ref $_[0] eq "HASH"
@_ == 1 ref $_[0] eq "HASH"
Truth table66%2/3
A and B
A= @_ == 1B= ref $_[0] eq "HASH"
ABresult
0X0
100
111
33 {
34 1 %args = %{$_[0]};
35 1 $pass_as_ref = !!1;
36 }
37 else
38 {
39 22 %args = @_;
40 22 $pass_as_ref = !!0;
41 }
42
43 23 ▶ my $traits_arr = delete($args{traits}) || [];
Condition100%2/2
delete $args{'traits'} || []
l!l
203
MC/DC100%1/1
delete $args{'traits'} || []
delete $args{'traits'}
Truth table100%2/2
A
A= delete $args{'traits'}
Aresult
11
00
44 23 ▶ my @traits = ref($traits_arr) ? @$traits_arr : $traits_arr;
Branch: 1 branch
BranchTrueFalseTotal
ref $traits_arr ? : 20 3 23
45 23 ▶ $class->with_traits(@traits)->new( $pass_as_ref ? \%args : %args );
Branch: 1 branch
BranchTrueFalseTotal
$pass_as_ref ? : 1 22 23
46 }
47  
48 8 1;
49  
50 __END__
« Traits/Util.pm ↑ Summary