PerlStyle/Functions.pm

filter: Statementstmt 100% 26 / 26 Branchbran 100% 8 / 8 Conditioncond 66.6% 4 / 6 MC/DCmcdc 50.0% 2 / 4 Subroutinesub 100% 6 / 6 Podpod 100% 1 / 1 totaltotal 92.1% 47 / 51 CC 7 SCAR 15.1
CC
7
Cov
95%
BACK
7.0
BEGIN
1.0
BEGIN
1.0
CRAP 4.5
« PerlStyle.pm ↑ Summary
1 package Struct::Path::PerlStyle::Functions;
2  
3 9 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 9 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 9 ▶use warnings FATAL => 'all';
Subroutine BEGIN: called CC=1 SCAR=0.0
6 9 ▶use parent 'Exporter';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 9 ▶use Scalar::Util qw(looks_like_number);
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 9 our @EXPORT_OK = qw(
11 BACK
12 back
13 );
14  
15 # INPORTANT: upper case should be used for function names to avoid clashes
16 # with existing perl functions and operators.
17  
18 =head1 NAME
19  
20 Struct::Path::PerlStyle::Functions - Collection handy functions for
21 L<Struct::Path::PerlStyle> hooks.
22  
23 =cut
24  
25 =head1 EXPORT
26  
27 Nothing is exported by default.
28  
29 =head1 Functions
30  
31 =head2 BACK, back
32  
33 Step back count times
34  
35 BACK(3); # go back 3 steps
36  
37 C<undef> returned when requested amount is greater than current step.
38 Lower-case 'back' is just an alias to 'BACK' for backward compatibility;
39 deprecated and will be removed in the future.
40  
41 =cut
42  
43 6 ▶sub BACK {
Subroutine BACK: called CC=7 SCAR=19.5
Pod documented
44 6 ▶ my $steps = defined $_[0] ? $_[0] : 1;
Branch: 1 branch
BranchTrueFalseTotal
defined $_[0] ? : 5 1 6
45  
46 6 ▶ return undef unless (looks_like_number $steps and int($steps) == $steps);
Branch: 1 branch
BranchTrueFalseTotal
unless &looks_like_number($steps) and int $steps == $steps 1 5 6
Condition66%2/3
&looks_like_number($steps) and int $steps == $steps
!ll&&!rl&&r
105
MC/DC50%1/2
&looks_like_number($steps) and int $steps == $steps
&looks_like_number($steps) int $steps == $steps
Truth table66%2/3
A and B
A= &looks_like_number($steps)B= int $steps == $steps
ABresult
0X0
100
111
47 5 ▶ return 1 if ($steps == 0);
Branch: 1 branch
BranchTrueFalseTotal
if $steps == 0 1 4 5
48 4 ▶ return undef if ($steps < 0 or $steps > @{$_{path}});
Branch: 1 branch
BranchTrueFalseTotal
if $steps < 0 or $steps > @{$_{"path"};} 1 3 4
Condition66%2/3
$steps < 0 or $steps > @{$_{"path"};}
l!l&&r!l&&!r
013
MC/DC50%1/2
$steps < 0 or $steps > @{$_{"path"};}
$steps < 0 $steps > @{$_{"path"};}
Truth table66%2/3
A or B
A= $steps < 0B= $steps > @{$_{"path"};}
ABresult
1X1
011
000
49  
50 3 splice @{$_{path}}, -$steps;
51 3 splice @{$_{refs}}, -$steps;
52 }
53  
54 9 *back = \&BACK; # for backward compatibility, deprecated
55  
56 =head1 AUTHOR
57  
58 Michael Samoglyadov, C<< <mixas at cpan.org> >>
59  
60 =head1 BUGS
61  
62 Please report any bugs or feature requests to
63 C<bug-struct-path-native at rt.cpan.org>, or through the web interface at
64 L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Struct-Path-PerlStyle>. I
65 will be notified, and then you'll automatically be notified of progress on
66 your bug as I make changes.
67  
68 =head1 SUPPORT
69  
70 You can find documentation for this module with the perldoc command.
71  
72 perldoc Struct::Path::PerlStyle::Functions
73  
74 You can also look for information at:
75  
76 =over 4
77  
78 =item * RT: CPAN's request tracker (report bugs here)
79  
80 L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Struct-Path-PerlStyle>
81  
82 =item * AnnoCPAN: Annotated CPAN documentation
83  
84 L<http://annocpan.org/dist/Struct-Path-PerlStyle>
85  
86 =item * CPAN Ratings
87  
88 L<http://cpanratings.perl.org/d/Struct-Path-PerlStyle>
89  
90 =item * Search CPAN
91  
92 L<http://search.cpan.org/dist/Struct-Path-PerlStyle/>
93  
94 =back
95  
96 =head1 SEE ALSO
97  
98 L<Struct::Path>, L<Struct::Diff>, L<perldsc>, L<perldata>
99  
100 =head1 LICENSE AND COPYRIGHT
101  
102 Copyright 2018-2019 Michael Samoglyadov.
103  
104 This program is free software; you can redistribute it and/or modify it
105 under the terms of either: the GNU General Public License as published
106 by the Free Software Foundation; or the Artistic License.
107  
108 See L<http://dev.perl.org/licenses/> for more information.
109  
110 =cut
111  
112 9 1; # End of Struct::Path::PerlStyle::Functions
« PerlStyle.pm ↑ Summary