blib/lib/Tags/HTML/Messages.pm

filter: Statementstmt 53.0% 26 / 49 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 80.0% 8 / 10 Podpod 100% 1 / 1 totaltotal 47.9% 35 / 73 CC 8 SCAR 26.4
CC
8
Cov
43%
_check_messages
30.0
_process
20.0
BEGIN
1.0
CRAP 14.0
↑ Summary
1 package Tags::HTML::Messages;
2  
3 4 ▶use base qw(Tags::HTML);
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 4 ▶use Class::Utils qw(set_params);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 4 ▶use Error::Pure qw(err);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 4 ▶use Scalar::Util qw(blessed);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 4 our $VERSION = 0.03;
12  
13 # Constructor.
14 sub new {
15 7 ▶ my ($class, @params) = @_;
Subroutine new: called CC=1 SCAR=0.0
Pod documented
16  
17 # Create object.
18 7 my $self = $class->SUPER::new(@params);
19  
20 # Object.
21 5 return $self;
22 }
23  
24 sub _check_messages {
25 0 ▶ my ($self, $message_ar) = @_;
Subroutine _check_messages: not called CC=5 SCAR=34.0
26  
27 0 ▶ if (ref $message_ar ne 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $message_ar ne "ARRAY") 0 0 0
28 0 err "Bad list of messages.";
29 }
30 0 foreach my $message (@{$message_ar}) {
31 0 ▶ if (! blessed($message) || ! $message->isa('Data::Message::Simple')) {
Branch: 1 branch
BranchTrueFalseTotal
unless (builtin::blessed($message) and $message->isa("Data::Message::Simple")) 0 0 0
Condition0%0/3
builtin::blessed($message) and $message->isa("Data::Message::Simple")
!ll&&!rl&&r
000
MC/DC0%0/2
builtin::blessed($message) and $message->isa("Data::Message::Simple")
builtin::blessed($message) $message->isa("Data::Message::Simple")
Truth table0%0/3
A and B
A= builtin::blessed($message)B= $message->isa("Data::Message::Simple")
ABresult
0X0
100
111
32  
33 0 err 'Bad message data object.';
34 }
35 }
36  
37 0 return;
38 }
39  
40 # Process 'Tags'.
41 sub _process {
42 0 ▶ my ($self, $message_ar) = @_;
Subroutine _process: not called CC=4 SCAR=30.0
43  
44 0 $self->_check_messages($message_ar);
45  
46 0 my $num = 0;
47 0 $self->{'tags'}->put(
48 ['b', 'div'],
49 ['a', 'class', 'messages'],
50 );
51 0 ▶ if (@{$message_ar}) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$message_ar;}) { } 0 0 0
52 0 foreach my $message (@{$message_ar}) {
53 0 ▶ if ($num) {
Branch: 1 branch
BranchTrueFalseTotal
if ($num) 0 0 0
54 0 $self->{'tags'}->put(
55 ['b', 'br'],
56 ['e', 'br'],
57 );
58 }
59 0 $self->{'tags'}->put(
60 ['b', 'span'],
61 ['a', 'class', $message->type],
62 ['d', $message->text],
63 ['e', 'span'],
64 );
65 0 $num++;
66 }
67 } else {
68 0 $self->{'tags'}->put(
69 ['d', 'No messages'],
70 );
71 }
72 0 $self->{'tags'}->put(
73 ['e', 'div'],
74 );
75  
76 0 return;
77 }
78  
79 # Process 'CSS::Struct'.
80 sub _process_css {
81 1 ▶ my ($self, $type, $color) = @_;
Subroutine _process_css: called CC=1 SCAR=0.0
82  
83 1 $self->{'css'}->put(
84 ['s', '.'.$type],
85 ['d', 'color', $color],
86 ['e'],
87 );
88  
89 1 return;
90 }
91  
92 4 1;
93  
94 __END__
↑ Summary