Min/NoteGrp.pm

filter: Statementstmt 33.3% 11 / 33 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 8 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 50.0% 3 / 6 Podpod 100% 3 / 3 totaltotal 26.1% 17 / 65 CC 9 SCAR 30.7
CC
9
Cov
22%
new
42.0
add_note
12.0
notes
6.0
CRAP 21.6
↑ Summary Min/TIG.pm »
1 #
2 # This file is part of TBX-Min
3 #
4 # This software is copyright (c) 2016 by Alan Melby.
5 #
6 # This is free software; you can redistribute it and/or modify it under
7 # the same terms as the Perl 5 programming language system itself.
8 #
9 package TBX::Min::NoteGrp;
10 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 1 our $VERSION = '0.08'; # VERSION
15  
16 # ABSTRACT: Store information from one TBX-Min C<noteGrp> element
17  
18 0 ▶sub new {
Subroutine new: not called CC=6 SCAR=37.4
Pod documented
19 0 my ($class, $args) = @_;
20  
21 0 my $self;
22 0 ▶ if((ref $args) eq 'HASH'){
Branch: 1 branch
BranchTrueFalseTotal
if (ref $args eq 'HASH') { } 0 0 0
23 # only 'notes' allowed in input hash
24 0 ▶ if(my @invalids = grep {$_ ne 'notes'} sort keys %$args){
Branch: 1 branch
BranchTrueFalseTotal
if (my(@invalids) = grep({$_ ne "notes";} sort(keys %$args))) 0 0 0
25 0 croak 'Invalid attributes for class: ' .
26 join ' ', @invalids
27 }
28 0 ▶ if($args->{notes} && ref $args->{notes} ne 'ARRAY'){
Branch: 1 branch
BranchTrueFalseTotal
if ($args->{"notes"} and ref $args->{"notes"} ne "ARRAY") 0 0 0
Condition0%0/3
$args->{"notes"} and ref $args->{"notes"} ne "ARRAY"
!ll&&!rl&&r
000
MC/DC0%0/2
$args->{"notes"} and ref $args->{"notes"} ne "ARRAY"
$args->{"notes"} ref $args->{"notes"} ne "ARRAY"
Truth table0%0/3
A and B
A= $args->{"notes"}B= ref $args->{"notes"} ne "ARRAY"
ABresult
0X0
100
111
29 0 croak q{Attribute 'notes' should be an array reference};
30 }
31 0 $self = $args;
32 }else{
33 0 $self = {};
34 }
35 0 ▶ $self->{notes} ||= [];
Condition0%0/2
$self->{"notes"} ||= []
l!l
00
MC/DC0%0/1
$self->{"notes"} ||= []
$self->{"notes"}
Truth table0%0/2
A
A= $self->{"notes"}
Aresult
11
00
36 0 return bless $self, $class;
37 }
38  
39 0 ▶sub notes { ## no critic(RequireArgUnpacking)
Subroutine notes: not called CC=2 SCAR=17.9
Pod documented
40 0 my ($self) = @_;
41 0 ▶ if (@_ > 1){
Branch: 1 branch
BranchTrueFalseTotal
if (@_ > 1) 0 0 0
42 0 croak 'extra argument found (notes is a getter only)';
43 }
44 0 return $self->{notes};
45 }
46  
47 0 ▶sub add_note {
Subroutine add_note: not called CC=3 SCAR=24.8
Pod documented
48 0 my ($self, $note) = @_;
49 0 ▶ if( !$note || !$note->isa('TBX::Min::Note') ){
Branch: 1 branch
BranchTrueFalseTotal
unless ($note and $note->isa("TBX::Min::Note")) 0 0 0
Condition0%0/3
$note and $note->isa("TBX::Min::Note")
!ll&&!rl&&r
000
MC/DC0%0/2
$note and $note->isa("TBX::Min::Note")
$note $note->isa("TBX::Min::Note")
Truth table0%0/3
A and B
A= $noteB= $note->isa("TBX::Min::Note")
ABresult
0X0
100
111
50 0 croak 'argument to add_note should be a TBX::Min::Note';
51 }
52 0 push @{$self->{notes}}, $note;
53 0 return;
54 }
55  
56  
57 1 1;
58  
59 __END__
↑ Summary Min/TIG.pm »