Part/Action.pm

filter: Statementstmt 57.1% 24 / 42 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 70.0% 7 / 10 Podpod 100% 3 / 3 totaltotal 51.5% 34 / 66 CC 5 SCAR 15.7
CC
5
Cov
47%
_check_part_transfer_class
12.0
load_design_id
6.0
load_element_id
6.0
CRAP 4.8
↑ Summary Part/Transfer.pm »
1 package Lego::Part::Action;
2  
3 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 3 ▶use Class::Utils qw(set_params);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 3 ▶use English;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 ▶use Error::Pure qw(err);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 3 ▶use Scalar::Util qw(blessed);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 3 our $VERSION = 0.04;
12  
13 # Constructor.
14 1 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
15 1 my ($class, @params) = @_;
16  
17 # Create object.
18 1 my $self = bless {}, $class;
19  
20 # Process parameters.
21 1 set_params($self, @params);
22  
23 # Object.
24 1 return $self;
25 }
26  
27 # Load design id to Lego::Part object.
28 0 ▶sub load_design_id {
Subroutine load_design_id: not called CC=2 SCAR=17.9
Pod documented
29 0 my ($self, $part_transfer_class, $part) = @_;
30 0 $self->_check_part_transfer_class($part_transfer_class);
31 0 eval {
32 0 $part_transfer_class->element2design($part);
33 };
34 0 ▶ if ($EVAL_ERROR) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Lego::Part::Action::EVAL_ERROR) 0 0 0
35 0 err 'Cannot load design ID.',
36 'Error', $EVAL_ERROR;
37 }
38 0 return;
39 }
40  
41 # Load element id to Lego::Part object.
42 0 ▶sub load_element_id {
Subroutine load_element_id: not called CC=2 SCAR=17.9
Pod documented
43 0 my ($self, $part_transfer_class, $part) = @_;
44 0 $self->_check_part_transfer_class($part_transfer_class);
45 0 eval {
46 0 $part_transfer_class->design2element($part);
47 };
48 0 ▶ if ($EVAL_ERROR) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Lego::Part::Action::EVAL_ERROR) 0 0 0
49 0 err 'Cannot load element ID.',
50 'Error', $EVAL_ERROR;
51 }
52 0 return;
53 }
54  
55 # Check transfer class.
56 0 ▶sub _check_part_transfer_class {
Subroutine _check_part_transfer_class: not called CC=3 SCAR=24.8
57 0 my ($self, $part_transfer_class) = @_;
58 0 ▶ if (! blessed($part_transfer_class)
Branch: 1 branch
BranchTrueFalseTotal
unless (builtin::blessed($part_transfer_class) and $part_transfer_class->isa("Lego::Part::Transfer")) 0 0 0
Condition0%0/3
builtin::blessed($part_transfer_class) and $part_transfer_class->isa("Lego::Part::Transfer")
!ll&&!rl&&r
000
MC/DC0%0/2
builtin::blessed($part_transfer_class) and $part_transfer_class->isa("Lego::Part::Transfer")
builtin::blessed($part_transfer_class) $part_transfer_class->isa("Lego::Part::Transfer")
Truth table0%0/3
A and B
A= builtin::blessed($part_transfer_class)B= $part_transfer_class->isa("Lego::Part::Transfer")
ABresult
0X0
100
111
59 || ! $part_transfer_class->isa('Lego::Part::Transfer')) {
60  
61 0 err "Bad transfer class. Must be 'Lego::Part::Transfer' ".
62 'class.';
63 }
64 0 return;
65 }
66  
67 3 1;
68  
69 __END__
↑ Summary Part/Transfer.pm »