test-lib/Car/Factory.pm

filter: Statementstmt 82.7% 24 / 29 Branchbran 20.0% 2 / 10 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 7 / 7 Podpod 0.0% 0 / 2 totaltotal 64.1% 34 / 53 CC 7 SCAR 20.1
CC
7
Cov
64%
createCar
14.5
new
2.5
BEGIN
1.0
CRAP 7.5
« lib/Class/Interface.pm ↑ Summary test-lib/Car/German.pm »
1 package Car::Factory;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 2 ▶use Class::Interface;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 2 &extends('Car::AbstractFactory');
8  
9 2 ▶use Car::Fiat;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use Car::Ford;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶use Car::Mercedes;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 # not using Car::BMW - it requires Class::AccessorMaker which you may
14 # not have.
15  
16 1 ▶sub new {
Subroutine new: called CC=2 SCAR=9.2
Pod undocumented
17 1 ▶ return bless( {}, ref( $_[0] ) || $_[0] );
Condition33%1/3
ref $_[0] || $_[0]
l!l&&r!l&&!r
010
MC/DC0%0/2
ref $_[0] || $_[0]
ref $_[0] $_[0]
Truth table33%1/3
A || B
A= ref $_[0]B= $_[0]
ABresult
1X1
011
000
18 }
19  
20 1 ▶sub createCar {
Subroutine createCar: called CC=6 SCAR=26.8
Pod undocumented
21 1 my ( $self, $car ) = @_;
22  
23 1 my $created;
24 1 ▶ if ( lc($car) eq "fiat" ) {
Branch: 4 branches
BranchTrueFalseTotal
if (lc $car eq 'fiat') { } 0 1 1
elsif (lc $car eq 'ford') { } 1 0 1
elsif (lc $car eq 'mercedes') { } 0 0 0
elsif (lc $car eq 'bmw') { } 0 0 0
25 0 $created = Car::Fiat->new();
26  
27 } elsif ( lc($car) eq "ford" ) {
28 1 $created = Car::Ford->new();
29  
30 } elsif ( lc($car) eq "mercedes" ) {
31 0 $created = Car::Mercedes->new();
32  
33 } elsif ( lc($car) eq "bmw" ) {
34 0 eval qq{ use Car::BMW };
35 0 ▶ $created = Car::BMW->new() unless $@;
Branch: 1 branch
BranchTrueFalseTotal
unless $@ 0 0 0
36  
37 } else {
38 0 die "Cannot build cars of type $car (yet)";
39 }
40  
41 1 $self->rememberCreatedCar($car);
42  
43 1 return $created;
44 }
45  
46 2 1;
« lib/Class/Interface.pm ↑ Summary test-lib/Car/German.pm »