Set.pm

filter: Statementstmt 84.0% 37 / 44 Branchbran 64.2% 9 / 14 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 91.6% 11 / 12 Podpod 100% 9 / 9 totaltotal 79.7% 67 / 84 CC 9 SCAR 7.8
CC
9
Cov
77%
unite
3.6
lookup
3.1
set_property
2.1
CRAP 2.2
« Set/Storage/DBIC.pm ↑ Summary Set/Storage/Split.pm »
1 package Context::Set;
2  
3 6 our $VERSION = '0.02';
4  
5 6 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7  
8 6 has 'name' => ( is => 'ro', isa => 'Str', default => 'UNIVERSE' );
9 65 ▶has 'properties' => ( is => 'rw' , isa => 'HashRef' , required => 1 , default => sub{ {}; } );
Subroutine __ANON__: called CC=1 SCAR=0.0
10  
11  
12 273 ▶sub fullname{
Subroutine fullname: called CC=1 SCAR=0.0
Pod documented
13 273 my ($self) = @_;
14 273 return $self->name();
15 }
16  
17 31 ▶sub is_inside{
Subroutine is_inside: called CC=1 SCAR=0.0
Pod documented
18 31 my ($self , $name) = @_;
19 31 return $self->name() eq $name;
20 }
21  
22 8 ▶sub restrict{
Subroutine restrict: called CC=2 SCAR=7.4
Pod documented
23 8 my ($self, $restriction_name) = @_;
24 8 ▶ unless( $restriction_name ){
Branch: 1 branch
BranchTrueFalseTotal
unless ($restriction_name) 0 8 8
25 0 confess("Missing restriction_name");
26 }
27 ## Avoid circular dependencies.
28 8 require Context::Set::Restriction;
29 8 return Context::Set::Restriction->new({ name => $restriction_name,
30 restricted => $self });
31 }
32  
33  
34 6 ▶sub unite{
Subroutine unite: called CC=3 SCAR=12.7
Pod documented
35 6 my ($self, $other) = @_;
36 6 ▶ unless( $other && $other->isa('Context::Set') ){
Branch: 1 branch
BranchTrueFalseTotal
unless ($other and $other->isa("Context::Set")) 0 6 6
Condition33%1/3
$other and $other->isa("Context::Set")
!ll&&!rl&&r
006
MC/DC0%0/2
$other and $other->isa("Context::Set")
$other $other->isa("Context::Set")
Truth table33%1/3
A and B
A= $otherB= $other->isa("Context::Set")
ABresult
0X0
100
111
37 0 confess("Missing other Context in unite");
38 }
39 6 require Context::Set::Union;
40 6 return Context::Set::Union->new({ contexts => [ $self, $other ] });
41 }
42  
43  
44 38 ▶sub set_property{
Subroutine set_property: called CC=2 SCAR=7.6
Pod documented
45 38 my ($self, $prop_name, $value) = @_;
46 38 ▶ unless( defined $prop_name ){
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $prop_name) 0 38 38
47 0 confess("prop_name has to be a defined value");
48 }
49 38 $self->properties()->{$prop_name} = $value;
50 }
51  
52  
53 28 ▶sub get_property{
Subroutine get_property: called CC=2 SCAR=6.9
Pod documented
54 28 my ($self, $prop_name) = @_;
55 28 ▶ unless( $self->has_property($prop_name) ){
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->has_property($prop_name)) 4 24 28
56 4 confess("No property named $prop_name in ".$self->name());
57 }
58 24 return $self->properties()->{$prop_name};
59 }
60  
61  
62 54 ▶sub has_property{
Subroutine has_property: called CC=1 SCAR=0.0
Pod documented
63 54 my ($self, $prop_name) = @_;
64 54 return exists $self->properties()->{$prop_name};
65 }
66  
67 4 ▶sub delete_property{
Subroutine delete_property: called CC=2 SCAR=7.6
Pod documented
68 4 my ($self, $prop_name) = @_;
69 4 ▶ unless( $self->has_property($prop_name) ){
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->has_property($prop_name)) 0 4 4
70 0 confess("No property named $prop_name in ".$self->name()." cannot delete it");
71 }
72 4 return delete $self->properties()->{$prop_name};
73 }
74  
75 6 ▶sub lookup{
Subroutine lookup: called CC=3 SCAR=11.3
Pod documented
76 6 my ($self, $prop_name) = @_;
77 0 ▶ unless( $prop_name ){ confess("Missing prop_name"); }
Branch: 1 branch
BranchTrueFalseTotal
unless ($prop_name) 0 6 6
78 6 ▶ return $self if $self->properties()->{$prop_name};
Branch: 1 branch
BranchTrueFalseTotal
if $self->properties->{$prop_name} 3 3 6
79 3 return $self->_lookup_parents($prop_name);
80 }
81  
82 0 ▶sub _lookup_parents{
Subroutine _lookup_parents: not called CC=1 SCAR=6.9
83 0 my ($self, $pname) = @_;
84 0 return undef;
85 }
86  
87 6 __PACKAGE__->meta->make_immutable();
88 6 1;
89 __END__
« Set/Storage/DBIC.pm ↑ Summary Set/Storage/Split.pm »