Part/Action.pm

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