Shipment/Generic.pm

filter: Statementstmt 85.3% 35 / 41 Branchbran 25.0% 2 / 8 Conditioncond 50.0% 3 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 90.0% 9 / 10 Podpod 100% 3 / 3 totaltotal 73.2% 52 / 71 CC 10 SCAR 18.5
CC
10
Cov
73%
ship
12.8
rate
3.0
cancel
2.0
CRAP 6.4
« Shipment/FedEx/WSDL/ShipInterfaces/ShipService/ShipServicePort.pm ↑ Summary Shipment/Address.pm »
1 package Shipment::Generic;
2 1 $Shipment::Generic::VERSION = '3.11';
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6  
7 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 extends 'Shipment::Base';
9  
10  
11 1 ▶sub _build_services {
Subroutine _build_services: called CC=1 SCAR=0.0
12 1 { generic => Shipment::Service->new(
13 id => 'generic',
14 name => 'Generic Service',
15 ),
16 }
17 }
18  
19  
20 2 ▶sub rate {
Subroutine rate: called CC=3 SCAR=11.1
Pod documented
21 2 my ($self, $service_id, $rate) = @_;
22  
23 2 ▶ $service_id ||= 'generic';
Condition50%1/2
$service_id ||= "generic"
l!l
20
MC/DC0%0/1
$service_id ||= "generic"
$service_id
Truth table50%1/2
A
A= $service_id
Aresult
11
00
24 2 ▶ $rate ||= 0;
Condition50%1/2
$rate ||= 0
l!l
20
MC/DC0%0/1
$rate ||= 0
$rate
Truth table50%1/2
A
A= $rate
Aresult
11
00
25  
26 1 ▶ use Data::Currency;
Subroutine BEGIN: called CC=1 SCAR=0.0
27 1 ▶ use Shipment::Service;
Subroutine BEGIN: called CC=1 SCAR=0.0
28 2 $self->service(
29 Shipment::Service->new(
30 id => $service_id,
31 name => $service_id,
32 cost => Data::Currency->new($rate, $self->currency),
33 )
34 );
35  
36 }
37  
38  
39 1 ▶sub ship {
Subroutine ship: called CC=8 SCAR=25.5
Pod documented
40 1 my ($self, $service_id, $tracking_id, $rate) = @_;
41  
42 1 $self->rate($service_id, $rate);
43  
44 1 ▶ if (!$tracking_id) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($tracking_id) 0 1 1
45 0 foreach (@{$self->packages}) {
46 0 ▶ $tracking_id = $_->tracking_id if $_->tracking_id;
Branch: 1 branch
BranchTrueFalseTotal
if $_->tracking_id 0 0 0
47 0 ▶ last if $_->tracking_id;
Branch: 1 branch
BranchTrueFalseTotal
if $_->tracking_id 0 0 0
48 }
49 }
50  
51 1 ▶ $tracking_id ||= 'n/a';
Condition50%1/2
$tracking_id ||= "n/a"
l!l
10
MC/DC0%0/1
$tracking_id ||= "n/a"
$tracking_id
Truth table50%1/2
A
A= $tracking_id
Aresult
11
00
52  
53 1 $self->tracking_id($tracking_id);
54  
55 1 ▶ use Shipment::Label;
Subroutine BEGIN: called CC=1 SCAR=0.0
56  
57 1 foreach (@{$self->packages}) {
58 1 ▶ $_->tracking_id($tracking_id) if !$_->tracking_id;
Branch: 1 branch
BranchTrueFalseTotal
unless $_->tracking_id 1 0 1
59 1 $_->label(
60 Shipment::Label->new(
61 { tracking_id => $_->tracking_id,
62 content_type => 'text/plain',
63 data => qq|
64 FROM:
65 | . $self->from_address->name . qq|
66 | . $self->from_address->company . qq|
67 | . $self->from_address->address1 . qq|
68 | . $self->from_address->address2 . qq|
69 |
70 . $self->from_address->city . qq|, |
71 . $self->from_address->province_code . qq| |
72 . $self->from_address->postal_code . qq|
73 | . $self->from_address->country_code . qq|
74 | . $self->from_address->phone . qq|
75  
76 TO:
77 | . $self->to_address->name . qq|
78 | . $self->to_address->company . qq|
79 | . $self->to_address->address1 . qq|
80 | . $self->to_address->address2 . qq|
81 |
82 . $self->to_address->city . qq|, |
83 . $self->to_address->province_code . qq| |
84 . $self->to_address->postal_code . qq|
85 | . $self->to_address->country_code . qq|
86 | . $self->to_address->phone . qq|
87 |,
88 file_name => $_->tracking_id . '.txt',
89 },
90 )
91 );
92 }
93  
94 }
95  
96  
97 0 ▶sub cancel {
Subroutine cancel: not called CC=1 SCAR=6.9
Pod documented
98 0 my $self = shift;
99  
100 0 return 'success';
101 }
102  
103  
104 1 1;
105  
106 __END__
« Shipment/FedEx/WSDL/ShipInterfaces/ShipService/ShipServicePort.pm ↑ Summary Shipment/Address.pm »