Dumper/Context/Table.pm

filter: Statementstmt 93.8% 46 / 49 Branchbran 87.5% 7 / 8 Conditioncond 66.6% 4 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 92.3% 12 / 13 Podpod 0.0% 0 / 7 totaltotal 80.2% 69 / 86 CC 8 SCAR 7.7
CC
8
Cov
90%
set
4.0
objects
3.1
new
2.0
CRAP 2.2
« Dumper/Context/Value/Inline.pm ↑ Summary Dumper/String.pm »
1 package TOML::Dumper::Context::Table;
2 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 2 ▶use Class::Accessor::Lite ro => [qw/name tree inline/];
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 2 ▶use TOML::Dumper::Name;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use TOML::Dumper::Context::Array;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use TOML::Dumper::Context::Value;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 9 ▶sub new {
Subroutine new: called CC=2 SCAR=6.9
Pod undocumented
12 9 my ($class, %args) = @_;
13 9 my ($name, $tree) = @args{qw/name tree/};
14 9 my $self = bless {
15 name => $name,
16 tree => {},
17 } => $class;
18 9 for my $name (keys %$tree) {
19 25 $self->set($name => $tree->{$name});
20 }
21 9 return $self;
22 }
23  
24 8 ▶sub depth { scalar @{ shift->{name} } }
Subroutine depth: called CC=1 SCAR=0.0
Pod undocumented
25 8 ▶sub priority { 0 }
Subroutine priority: called CC=1 SCAR=0.0
Pod undocumented
26  
27 25 ▶sub set {
Subroutine set: called CC=4 SCAR=13.9
Pod undocumented
28 25 my ($self, $name, $object) = @_;
29 25 ▶ my @name = defined $self->{name} ? (@{ $self->{name} }, $name) : ($name);
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{'name'} ? : 25 0 25
30 25 ▶ if (ref $object eq 'HASH') {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $object eq 'HASH') { } 3 22 25
elsif (ref $object eq 'ARRAY') { } 5 17 22
31 3 $self->{tree}->{$name} = TOML::Dumper::Context::Table->new(name => \@name, tree => $object);
32 }
33 elsif (ref $object eq 'ARRAY') {
34 5 $self->{tree}->{$name} = TOML::Dumper::Context::Array->new(name => \@name, objects => $object);
35 }
36 else {
37 17 $self->{tree}->{$name} = TOML::Dumper::Context::Value->new(name => \@name, atom => $object);
38 }
39 25 return $self;
40 }
41  
42 0 ▶sub remove {
Subroutine remove: not called CC=1 SCAR=6.9
Pod undocumented
43 0 my ($self, $name) = @_;
44 0 delete $self->{tree}->{$name};
45 0 return $self;
46 }
47  
48 9 ▶sub objects {
Subroutine objects: called CC=3 SCAR=11.2
Pod undocumented
49 9 my $self = shift;
50 9 ▶ return sort { $a->depth <=> $b->depth || $b->priority <=> $a->priority || $a->name->[-1] cmp $b->name->[-1] } values %{ $self->{tree} };
Condition66%4/6
$a->depth <=> $b->depth || $b->priority <=> $a->priority || $a->name->[-1] cmp $b->name->[-1]
l!l&&r!l&&!r
12210
$a->depth <=> $b->depth or $b->priority <=> $a->priority
l!l&&r!l&&!r
01221
MC/DC0%0/3
$a->depth <=> $b->depth || $b->priority <=> $a->priority || $a->name->[-1] cmp $b->name->[-1]
$a->depth <=> $b->depth $b->priority <=> $a->priority $a->name->[-1] cmp $b->name->[-1]
Truth table50%2/4
A or B || C
A= $a->depth <=> $b->depthB= $b->priority <=> $a->priorityC= $a->name->[-1] cmp $b->name->[-1]
ABCresult
1XX1
01X1
0011
0000
51 }
52  
53 4 ▶sub as_string {
Subroutine as_string: called CC=2 SCAR=6.9
Pod undocumented
54 4 my $self = shift;
55 4 my $name = $self->{name};
56 4 ▶ my $body = @$name ? "\n".'['.TOML::Dumper::Name::join(@$name).']'."\n" : '';
Branch: 1 branch
BranchTrueFalseTotal
@$name ? : 3 1 4
57 4 $body .= join "\n", map { $_->as_string() } $self->objects;
58 4 return $body;
59 }
60  
61 2 1;
« Dumper/Context/Value/Inline.pm ↑ Summary Dumper/String.pm »