TagSet.pm

filter: Statementstmt 83.6% 51 / 61 Branchbran 57.6% 15 / 26 Conditioncond 33.3% 2 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 87.5% 14 / 16 Podpod 0.0% 0 / 7 totaltotal 68.3% 82 / 120 CC 17 SCAR 27.9
CC
17
Cov
73%
_args
35.3
new
3.0
__ANON__
2.0
CRAP 16.3
« Parser.pm ↑ Summary Tag/IMG.pm »
1 # $Id: TagSet.pm 284 2006-12-01 07:51:49Z chronos $
2 package BBCode::TagSet;
3 6 ▶use BBCode::Util qw(:tag);
Subroutine BEGIN: called CC=1 SCAR=0.0
4 6 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
5 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 6 our $VERSION = '0.34';
8  
9 315 ▶sub new($@):method {
Subroutine new: called CC=3 SCAR=11.0
Pod undocumented
10 315 my $class = shift;
11 315 ▶ $class = ref($class) || $class;
Condition66%2/3
ref $class || $class
l!l&&r!l&&!r
123030
MC/DC0%0/2
ref $class || $class
ref $class $class
Truth table66%2/3
A || B
A= ref $classB= $class
ABresult
1X1
011
000
12 315 my $this = bless {}, $class;
13 315 ▶ $this->add(@_) if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 13 302 315
14 315 return $this;
15 }
16  
17 174 ▶sub keys($):method {
Subroutine keys: called CC=1 SCAR=0.0
Pod undocumented
18 174 return keys %{+shift};
19 }
20  
21 12 ▶sub clone($):method {
Subroutine clone: called CC=1 SCAR=0.0
Pod undocumented
22 12 my $this = shift;
23 12 my $that = $this->new();
24 12 $that->add($this);
25 12 return $that;
26 }
27  
28 326 ▶sub _args {
Subroutine _args: called CC=14 SCAR=35.6
29 326 my($std,$not) = splice @_, 0, 2;
30 326 ▶ while(@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 439 326 765
31 439 my $arg = shift;
32  
33 439 ▶ if(ref $arg) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $arg) { } 174 265 439
34 174 ▶ if(UNIVERSAL::isa($arg,'BBCode::TagSet')) {
Branch: 5 branches
BranchTrueFalseTotal
if (UNIVERSAL::isa($arg, 'BBCode::TagSet')) { } 174 0 174
elsif (UNIVERSAL::isa($arg, 'BBCode::Tag')) { } 0 0 0
elsif (ref $arg eq 'HASH') { } 0 0 0
elsif (ref $arg eq 'ARRAY') { } 0 0 0
elsif (ref $arg eq 'SCALAR' or ref $arg eq 'REF') { } 0 0 0
35 174 foreach($arg->keys) {
36 38 $std->();
37 }
38 } elsif(UNIVERSAL::isa($arg,'BBCode::Tag')) {
39 0 local $_ = $arg->Tag;
40 0 $std->();
41 } elsif(ref $arg eq 'HASH') {
42 0 unshift @_, keys %$arg;
43 } elsif(ref $arg eq 'ARRAY') {
44 0 unshift @_, @$arg;
45 ▶ } elsif(ref $arg eq 'SCALAR' or ref $arg eq 'REF') {
Condition0%0/3
ref $arg eq "SCALAR" or ref $arg eq "REF"
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $arg eq "SCALAR" or ref $arg eq "REF"
ref $arg eq "SCALAR" ref $arg eq "REF"
Truth table0%0/3
A or B
A= ref $arg eq "SCALAR"B= ref $arg eq "REF"
ABresult
1X1
011
000
46 0 unshift @_, $$arg;
47 } else {
48 0 croak qq(Invalid reference);
49 }
50 } else {
51 265 ▶ if($arg =~ /^(!?)(:\w+)$/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($arg =~ /^(!?)(:\w+)$/) { } 171 94 265
elsif ($arg =~ /^(!?)(\w+)$/) { } 94 0 94
52 171 local $_ = uc($2);
53 171 ▶ (($1 eq '') ? $std : $not)->();
Branch: 1 branch
BranchTrueFalseTotal
$1 eq '' ? : 158 13 171
54 } elsif($arg =~ /^(!?)(\w+)$/) {
55 94 local $_ = tagCanonical($2);
56 94 ▶ (($1 eq '') ? $std : $not)->();
Branch: 1 branch
BranchTrueFalseTotal
$1 eq '' ? : 94 0 94
57 } else {
58 0 croak qq(Malformed tag [$arg]);
59 }
60 }
61 }
62 }
63  
64 245 ▶sub add($@):method {
Subroutine add: called CC=1 SCAR=0.0
Pod undocumented
65 245 my $this = shift;
66 _args(
67 277 ▶ sub { $this->{$_} = 1 },
Subroutine __ANON__: called CC=1 SCAR=0.0
68 13 ▶ sub { delete $this->{$_} },
Subroutine __ANON__: called CC=1 SCAR=0.0
69 245 @_,
70 );
71 245 return $this;
72 }
73  
74 81 ▶sub remove($@):method {
Subroutine remove: called CC=1 SCAR=0.1
Pod undocumented
75 81 my $this = shift;
76 _args(
77 13 ▶ sub { delete $this->{$_} },
Subroutine __ANON__: called CC=1 SCAR=0.0
78 0 ▶ sub { $this->{$_} = 1 },
Subroutine __ANON__: not called CC=1 SCAR=6.9
79 81 @_,
80 );
81 81 return $this;
82 }
83  
84 2919 ▶sub contains($$):method {
Subroutine contains: called CC=2 SCAR=6.9
Pod undocumented
85 2919 my $this = shift;
86 2919 my $tag = tagCanonical(shift);
87 2919 ▶ return 1 if exists $this->{$tag};
Branch: 1 branch
BranchTrueFalseTotal
if exists $this->{$tag} 467 2452 2919
88 2452 return 0;
89 }
90  
91 0 ▶sub toString($):method {
Subroutine toString: not called CC=1 SCAR=6.9
Pod undocumented
92 0 my $this = shift;
93 0 return join(" ", sort keys %$this);
94 }
95 6 *as_string = *toString;
96  
97 6 1;
« Parser.pm ↑ Summary Tag/IMG.pm »