lib/OODoc/Text/Section.pm

filter: Statementstmt 31.6% 19 / 60 Branchbran 0.0% 0 / 16 Conditioncond 0.0% 0 / 7 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 33.3% 5 / 15 Podpod 77.7% 7 / 9 totaltotal 27.9% 31 / 111 CC 14 SCAR 27.3
CC
14
Cov
23%
init
42.0
findSubroutine
20.0
findEntry
12.0
CRAP 15.4
« lib/OODoc/Text/Chapter.pm ↑ Summary lib/OODoc/Text/SubSection.pm »
1 # This code is part of Perl distribution OODoc version 3.05.
2 # The POD got stripped from this file by OODoc version 3.05.
3 # For contributors see file ChangeLog.
4  
5 # This software is copyright (c) 2003-2025 by Mark Overmeer.
6  
7 # This is free software; you can redistribute it and/or modify it under
8 # the same terms as the Perl 5 programming language system itself.
9 # SPDX-License-Identifier: Artistic-1.0-Perl OR GPL-1.0-or-later
10  
11  
12 package OODoc::Text::Section;{
13 1 our $VERSION = '3.05';
14 }
15  
16 1 ▶use parent 'OODoc::Text::Structure';
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 1 ▶use Log::Report 'oodoc';
Subroutine BEGIN: called CC=1 SCAR=0.0
22 1 ▶use List::Util 'first';
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 #--------------------
25  
26 sub init($)
27 0 ▶{ my ($self, $args) = @_;
Subroutine init: not called CC=6 SCAR=37.4
Pod undocumented
28 0 ▶ $args->{type} ||= 'Section';
Condition0%0/2
$args->{"type"} ||= "Section"
l!l
00
MC/DC0%0/1
$args->{"type"} ||= "Section"
$args->{"type"}
Truth table0%0/2
A
A= $args->{"type"}
Aresult
11
00
29 0 ▶ $args->{level} ||= 2;
Condition0%0/2
$args->{"level"} ||= 2
l!l
00
MC/DC0%0/1
$args->{"level"} ||= 2
$args->{"level"}
Truth table0%0/2
A
A= $args->{"level"}
Aresult
11
00
30 0 ▶ $args->{container} ||= delete $args->{chapter} or panic;
Branch: 1 branch
BranchTrueFalseTotal
$args->{"container"} ||= delete $args->{"chapter"} or &panic() 0 0 0
Condition0%0/3
$args->{"container"} ||= delete $args->{"chapter"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$args->{"container"} ||= delete $args->{"chapter"}
$args->{"container"} delete $args->{"chapter"}
Truth table0%0/3
A ||= B
A= $args->{"container"}B= delete $args->{"chapter"}
ABresult
1X1
011
000
31  
32 0 ▶ $self->SUPER::init($args) or return;
Branch: 1 branch
BranchTrueFalseTotal
$self->SUPER::init($args) or return 0 0 0
33  
34 0 $self->{OTS_subsections} = [];
35 0 $self;
36 }
37  
38 sub emptyExtension($)
39 0 ▶{ my ($self, $container) = @_;
Subroutine emptyExtension: not called CC=1 SCAR=6.9
Pod documented
40 0 my $empty = $self->SUPER::emptyExtension($container);
41 0 my @subsections = map $_->emptyExtension($empty), $self->subsections;
42 0 $empty->subsections(@subsections);
43 0 $empty;
44 }
45  
46 #--------------------
47  
48 0 ▶sub chapter() { $_[0]->container }
Subroutine chapter: not called CC=1 SCAR=6.9
Pod documented
49  
50 sub path()
51 0 ▶{ my $self = shift;
Subroutine path: not called CC=1 SCAR=6.9
Pod documented
52 0 $self->chapter->path . '/' . $self->name;
53 }
54  
55 sub findSubroutine($)
56 0 ▶{ my ($self, $name) = @_;
Subroutine findSubroutine: not called CC=4 SCAR=30.0
Pod undocumented
57 0 my $sub = $self->SUPER::findSubroutine($name);
58 0 ▶ return $sub if defined $sub;
Branch: 1 branch
BranchTrueFalseTotal
if defined $sub 0 0 0
59  
60 0 foreach my $subsection ($self->subsections)
61 0 { my $sub = $subsection->findSubroutine($name);
62 0 ▶ return $sub if defined $sub;
Branch: 1 branch
BranchTrueFalseTotal
if defined $sub 0 0 0
63 }
64  
65 0 undef;
66 }
67  
68 sub findEntry($)
69 0 ▶{ my ($self, $name) = @_;
Subroutine findEntry: not called CC=3 SCAR=24.8
Pod documented
70 0 ▶ return $self if $self->name eq $name;
Branch: 1 branch
BranchTrueFalseTotal
if $self->name eq $name 0 0 0
71 0 my $subsect = $self->subsection($name);
72 0 ▶ defined $subsect ? $subsect : ();
Branch: 1 branch
BranchTrueFalseTotal
defined $subsect ? : 0 0 0
73 }
74  
75 sub all($@)
76 0 ▶{ my $self = shift;
Subroutine all: not called CC=1 SCAR=6.9
Pod documented
77 0 ( $self->SUPER::all(@_), map $_->all(@_), $self->subsections );
78 }
79  
80 #--------------------
81  
82 sub subsection($)
83 0 ▶{ my ($self, $thing) = @_;
Subroutine subsection: not called CC=2 SCAR=17.9
Pod documented
84 0 ▶ if(ref $thing)
Branch: 1 branch
BranchTrueFalseTotal
if (ref $thing) 0 0 0
85 0 { push @{$self->{OTS_subsections}}, $thing;
86 0 return $thing;
87 }
88  
89 0 ▶ first {$_->name eq $thing} $self->subsections;
Subroutine __ANON__: not called CC=1 SCAR=6.9
90 }
91  
92  
93 sub subsections(;@)
94 0 ▶{ my $self = shift;
Subroutine subsections: not called CC=3 SCAR=24.8
Pod documented
95 0 ▶ if(@_)
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
96 0 { $self->{OTS_subsections} = [ @_ ];
97 0 $_->container($self) for @_;
98 }
99  
100 0 @{$self->{OTS_subsections}};
101 }
102  
103 1 *nest = \*subsections;
104  
105 1 1;
« lib/OODoc/Text/Chapter.pm ↑ Summary lib/OODoc/Text/SubSection.pm »