Scaffold/Factory/Type.pm

filter: Statementstmt 64.7% 22 / 34 Branchbran 33.3% 2 / 6 Conditioncond 16.6% 1 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 72.7% 8 / 11 Podpod 100% 3 / 3 totaltotal 56.2% 36 / 64 CC 7 SCAR 12.6
CC
7
Cov
54%
import
6.4
make_object_for_type
6.0
register_factory_type
4.5
CRAP 3.5
« Scaffold/Base.pm ↑ Summary Scaffold/ConstantImporter.pm »
1 34 ▶use 5.008;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 34 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 34 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 package Class::Scaffold::Factory::Type;
6 34 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
7 34 $Class::Scaffold::Factory::Type::VERSION = '1.102280';
8 }
9 # ABSTRACT: Factory for framework object types
10 34 ▶use parent 'Class::Factory::Enhanced';
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 41 ▶sub import {
Subroutine import: called CC=4 SCAR=18.5
13 41 shift; # We don't need the package name
14 41 my $spec = shift;
15 41 ▶ return unless defined $spec && $spec eq ':all';
Branch: 1 branch
BranchTrueFalseTotal
unless defined $spec and $spec eq ":all" 41 0 41
Condition33%1/3
defined $spec and $spec eq ":all"
!ll&&!rl&&r
4100
MC/DC0%0/2
defined $spec and $spec eq ":all"
defined $spec $spec eq ":all"
Truth table33%1/3
A and B
A= defined $specB= $spec eq ":all"
ABresult
0X0
100
111
16 0 my $pkg = caller;
17 0 for my $symbol (Class::Scaffold::Factory::Type->get_registered_types) {
18 0 my $factory_class =
19 Class::Scaffold::Factory::Type->get_registered_class($symbol);
20 34 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
21 0 my $target = "${pkg}::obj_${symbol}";
22 0 ▶ *$target = sub () { $factory_class };
Subroutine __ANON__: not called CC=1 SCAR=6.9
23 }
24 }
25  
26 # override this method with a caching version; it's called very often
27 0 ▶sub make_object_for_type {
Subroutine make_object_for_type: not called CC=2 SCAR=17.9
Pod documented
28 0 my ($self, $object_type, @args) = @_;
29 0 our %cache;
30 0 ▶ my $class = $cache{$object_type} ||= $self->get_factory_class($object_type);
Condition0%0/3
$Class::Scaffold::Factory::Type::cache{$object_type} ||= $self->get_factory_class($object_type)
l!l&&r!l&&!r
000
MC/DC0%0/2
$Class::Scaffold::Factory::Type::cache{$object_type} ||= $self->get_factory_class($object_type)
$Class::Scaffold::Factory::Type::cache{$object_type} $self->get_factory_class($object_type)
Truth table0%0/3
A ||= B
A= $Class::Scaffold::Factory::Type::cache{$object_type}B= $self->get_factory_class($object_type)
ABresult
1X1
011
000
31 0 $class->new(@args);
32 }
33  
34 # no warnings
35 0 ▶sub factory_log { }
Subroutine factory_log: not called CC=1 SCAR=0.0
Pod documented
36  
37 8 ▶sub register_factory_type {
Subroutine register_factory_type: called CC=3 SCAR=15.1
Pod documented
38 8 my ($item, @args) = @_;
39 8 $item->SUPER::register_factory_type(@args);
40 8 ▶ return unless $::PTAGS;
Branch: 1 branch
BranchTrueFalseTotal
unless $main::PTAGS 8 0 8
41 0 ▶ while (my ($factory_type, $package) = splice @args, 0, 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = splice(@args, 0, 2)) 0 0 0
42 0 $::PTAGS->add_tag("csft--$factory_type", "filename_for:$package", 1);
43 }
44 }
45 34 1;
46  
47  
48 __END__
« Scaffold/Base.pm ↑ Summary Scaffold/ConstantImporter.pm »