| 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
| |||||||||||||||||||||||||||||
| 23 | # only 'notes' allowed in input hash | ||||||||||||||||||||||||||||
| 24 | 0 | ▶ | if(my @invalids = grep {$_ ne 'notes'} sort keys %$args){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 25 | 0 | croak 'Invalid attributes for class: ' . | |||||||||||||||||||||||||||
| 26 | join ' ', @invalids | ||||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||
| 28 | 0 | ▶ | if($args->{notes} && ref $args->{notes} ne 'ARRAY'){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$args->{"notes"} and ref $args->{"notes"} ne "ARRAY"
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"
| |||||||||||||||||||||||||||||
| 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"} ||= []
MC/DC0%0/1
$self->{"notes"} ||= []
$self->{"notes"}
Truth table0%0/2
A
A= $self->{"notes"}
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
Condition0%0/3
$note and $note->isa("TBX::Min::Note")
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")
| |||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||