Zest/Author/TABULO/Util/Mayhap.pm

filter: Statementstmt 95.6% 22 / 23 Branchbran 62.5% 5 / 8 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 1 totaltotal 79.0% 34 / 43 CC 7 SCAR 17.2
CC
7
Cov
82%
_undef_if_empty
8.8
BEGIN
1.0
BEGIN
1.0
CRAP 5.6
« Zest/Author/TABULO/Util/ShareDir.pm ↑ Summary Zest/Author/TABULO/Util/Text.pm »
1  
2 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 package Zest::Author::TABULO::Util::Mayhap;
6 2 our $VERSION = '1.000014';
7  
8 2 ▶use PerlX::Maybe qw(maybe);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use Exporter::Shiny qw(mayhap);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11  
12 #region: #== UTILITY FUNCTIONS (EXPORT_OK) ==
13  
14 ## no critic: Prototypes
15 13 ▶sub mayhap ($$@) { # the prototype is intentional here.
Subroutine mayhap: called CC=1 SCAR=0.0
Pod undocumented
16 13 my ( $arg1, $arg2 ) = ( shift, shift );
17 13 maybe $arg1 => _undef_if_empty($arg2), @_;
18 }
19  
20 13 ▶sub _undef_if_empty { # Utility function
Subroutine _undef_if_empty: called CC=7 SCAR=21.8
21 13 my $x = shift;
22 13 ▶ for ( ref $x // () ) {
Condition33%1/3
ref $x // ()
l!l&&r!l&&!r
1300
MC/DC0%0/2
ref $x // ()
ref $x ()
Truth table33%1/3
A // B
A= ref $xB= ()
ABresult
1X1
011
000
23 13 ▶ m/ARRAY/ and do { return ( @$x ? $x : undef ) };
Branch: 2 branches
BranchTrueFalseTotal
/ARRAY/ and do { return @$x ? $x : undef } 7 6 13
@$x ? : 5 2 7
24 0 ▶ m/HASH/ and do { return ( %$x ? $x : undef ) };
Branch: 2 branches
BranchTrueFalseTotal
/HASH/ and do { return %$x ? $x : undef } 0 6 6
%$x ? : 0 0 0
25 }
26 6 $x;
27 }
28  
29 #endregion (UTILITY FUNCTIONS)
30  
31 2 1;
32  
33 =pod
34  
35 =encoding UTF-8
36  
37 =for :stopwords Tabulo[n]
38  
39 =head1 NAME
40  
41 Zest::Author::TABULO::Util::Mayhap - Utility functions used by TABULO's authoring dist
42  
43 =head1 VERSION
44  
45 version 1.000014
46  
47 =for Pod::Coverage mayhap
48  
49 =head1 AUTHORS
50  
51 Tabulo[n] <dev@tabulo.net>
52  
53 =head1 LEGAL
54  
55 This software is copyright (c) 2023 by Tabulo[n].
56  
57 This is free software; you can redistribute it and/or modify it under
58 the same terms as the Perl 5 programming language system itself.
59  
60 =cut
61  
62 __END__
« Zest/Author/TABULO/Util/ShareDir.pm ↑ Summary Zest/Author/TABULO/Util/Text.pm »