lib/IPTV/Playlist/M3UTools.pm

filter: Statementstmt 100% 27 / 27 Branchbran 50.0% 4 / 8 Conditioncond 33.3% 2 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 3 totaltotal 72.2% 39 / 54 CC 7 SCAR 11.9
CC
7
Cov
80%
tool_url
4.5
playlist_url
4.4
BEGIN
1.0
CRAP 3.3
↑ Summary
1 package IPTV::Playlist::M3UTools;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Exporter qw(import);
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 our $VERSION = '0.2.0';
8 1 our @EXPORT_OK = qw(metadata playlist_url tool_url);
9  
10 1 my %TOOLS = (
11 checker => '/iptv-checker',
12 analyzer => '/m3u-playlist-analyzer',
13 viewer => '/m3u-viewer',
14 guides => '/guides',
15 );
16  
17 1 ▶sub playlist_url {
Subroutine playlist_url: called CC=4 SCAR=14.8
Pod undocumented
18 1 my ($country) = @_;
19 1 ▶ die 'value must be a non-empty string' if !defined($country) || ref($country);
Branch: 1 branch
BranchTrueFalseTotal
if not defined $country or ref $country 0 1 1
Condition33%1/3
not defined $country or ref $country
l!l&&r!l&&!r
001
MC/DC0%0/2
not defined $country or ref $country
not defined $country ref $country
Truth table33%1/3
not(A) or B
A= not defined $countryB= ref $country
ABresult
1X1
011
000
20 1 my $slug = lc $country;
21 1 $slug =~ s/[^a-z0-9]+/-/g;
22 1 $slug =~ s/^-+|-+$//g;
23 1 ▶ die 'value must be a non-empty string' if $slug eq '';
Branch: 1 branch
BranchTrueFalseTotal
if $slug eq "" 0 1 1
24 1 return "https://iptvplaylist.app/playlists/$slug";
25 }
26  
27 5 ▶sub tool_url {
Subroutine tool_url: called CC=4 SCAR=15.0
Pod undocumented
28 5 my ($tool) = @_;
29 5 ▶ die 'tool must be a supported string' if !defined($tool) || ref($tool);
Branch: 1 branch
BranchTrueFalseTotal
if not defined $tool or ref $tool 0 5 5
Condition33%1/3
not defined $tool or ref $tool
l!l&&r!l&&!r
005
MC/DC0%0/2
not defined $tool or ref $tool
not defined $tool ref $tool
Truth table33%1/3
not(A) or B
A= not defined $toolB= ref $tool
ABresult
1X1
011
000
30 5 $tool = lc $tool;
31 5 $tool =~ s/^\s+|\s+$//g;
32 5 ▶ die 'tool must be checker, analyzer, viewer, or guides' if !exists $TOOLS{$tool};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $TOOLS{$tool} 0 5 5
33 5 return 'https://iptvplaylist.app' . $TOOLS{$tool};
34 }
35  
36 1 ▶sub metadata {
Subroutine metadata: called CC=1 SCAR=0.0
Pod undocumented
37 return {
38 1 name => 'IPTV Playlist',
39 homepage => 'https://iptvplaylist.app/',
40 description => 'Public IPTV playlist directory and M3U utility site.',
41 canonicalPages => {
42 home => 'https://iptvplaylist.app/',
43 playlists => 'https://iptvplaylist.app/playlists',
44 checker => tool_url('checker'),
45 analyzer => tool_url('analyzer'),
46 viewer => tool_url('viewer'),
47 guides => tool_url('guides'),
48 },
49 tags => [qw(iptv m3u playlist)],
50 };
51 }
52  
53 1 1;
↑ Summary