lib/BalanceOfPower/Relations/TradeRoute.pm

filter: Statementstmt 62.8% 22 / 35 Branchbran 50.0% 4 / 8 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 71.4% 5 / 7 Podpod 0.0% 0 / 4 totaltotal 54.3% 31 / 57 CC 6 SCAR 11.4
CC
6
Cov
58%
dump
6.0
print
3.8
factor_for_node
3.1
CRAP 3.1
« blib/lib/BalanceOfPower/Commands/AidInsurgents.pm ↑ Summary blib/lib/BalanceOfPower/Relations/MilitarySupport.pm »
1 package BalanceOfPower::Relations::TradeRoute;
2 11 $BalanceOfPower::Relations::TradeRoute::VERSION = '0.200000';
3 11 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 11 ▶use v5.10;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 11 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 11 has factor1 => (
9 is => 'ro'
10 );
11 11 has factor2 => (
12 is => 'ro'
13 );
14  
15 11 with 'BalanceOfPower::Relations::Role::Relation';
16  
17 sub factor_for_node
18 {
19 280 ▶ my $self = shift;
Subroutine factor_for_node: called CC=3 SCAR=11.2
Pod undocumented
20 280 my $node = shift;
21 280 ▶ if ($self->node1 eq $node)
Branch: 2 branches
BranchTrueFalseTotal
if ($self->node1 eq $node) { } 137 143 280
elsif ($self->node2 eq $node) { } 143 0 143
22 {
23 137 return $self->factor1;
24 }
25 elsif ($self->node2 eq $node)
26 {
27 143 return $self->factor2;
28 }
29 else
30 {
31 0 return undef;
32 }
33 }
34 sub print
35 {
36 1 ▶ my $self = shift;
Subroutine print: called CC=3 SCAR=13.3
Pod undocumented
37 1 my $from = shift;
38 1 ▶ if($from eq $self->node1)
Branch: 2 branches
BranchTrueFalseTotal
if ($from eq $self->node1) { } 1 0 1
elsif ($from eq $self->node2) { } 0 0 0
39 {
40 1 return $from . " -[x" . $self->factor1 . "]-> " . $self->node2;
41 }
42 elsif($from eq $self->node2)
43 {
44 0 return $from . " -[x" . $self->factor2 . "]-> " . $self->node1;
45 }
46 }
47 sub dump
48 {
49 0 ▶ my $self = shift;
Subroutine dump: not called CC=2 SCAR=17.9
Pod undocumented
50 0 my $io = shift;
51 0 ▶ my $indent = shift || "";
Condition0%0/2
shift() || ''
l!l
00
MC/DC0%0/1
shift() || ''
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
52 0 print {$io} $indent . join(";", $self->node1, $self->node2, $self->factor1, $self->factor2) . "\n";
53 }
54 sub load
55 {
56 0 ▶ my $self = shift;
Subroutine load: not called CC=1 SCAR=6.9
Pod undocumented
57 0 my $data = shift;
58 0 $data =~ s/^\s+//;
59 0 chomp $data;
60 0 my ($node1, $node2, $factor1, $factor2) = split ";", $data;
61 0 return $self->new(node1 => $node1, node2 => $node2, factor1 => $factor1, factor2 => $factor2);
62 }
63  
64  
65  
66  
67  
68  
69 11 1;
70  
71  
« blib/lib/BalanceOfPower/Commands/AidInsurgents.pm ↑ Summary blib/lib/BalanceOfPower/Relations/MilitarySupport.pm »