ColorThemeBase/Static/FromStructColors.pm

filter: Statementstmt 96.4% 27 / 28 Branchbran 87.5% 7 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod 0.0% 0 / 2 totaltotal 90.4% 38 / 42 CC 5 SCAR 10.2
CC
5
Cov
94%
get_item_color
4.0
list_items
2.0
BEGIN
1.0
CRAP 2.8
« ColorTheme/Test/Dynamic.pm ↑ Summary ColorThemeBase/Base.pm »
1 package ColorThemeBase::Static::FromStructColors;
2  
3 4 ▶use strict 'subs', 'vars';
Subroutine BEGIN: called CC=1 SCAR=0.0
4 #use warnings;
5  
6 4 ▶use parent 'ColorThemeBase::Base';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 4 our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
9 4 our $DATE = '2024-07-17'; # DATE
10 4 our $DIST = 'ColorThemeBase-Static'; # DIST
11 4 our $VERSION = '0.009'; # VERSION
12  
13 2 ▶sub list_items {
Subroutine list_items: called CC=2 SCAR=6.9
Pod undocumented
14 2 my $self = shift;
15  
16 2 my $theme_hash = \%{"$self->{orig_class}::THEME"};
17 2 my @list = sort keys %{ $theme_hash->{items} };
18 2 ▶ wantarray ? @list : \@list;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 1 1 2
19 }
20  
21 6 ▶sub get_item_color {
Subroutine get_item_color: called CC=4 SCAR=13.9
Pod undocumented
22 6 my ($self, $name, $args) = @_;
23  
24 6 my $theme_hash = \%{"$self->{orig_class}::THEME"};
25  
26 6 my $c = $theme_hash->{items}{$name};
27 6 ▶ return unless defined $c;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $c 1 5 6
28  
29 5 ▶ if (ref $c eq 'CODE') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $c eq "CODE") 1 4 5
30 1 my $c2 = $c->($self, $name, $args);
31 1 ▶ if (ref $c2 eq 'CODE') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $c2 eq "CODE") 0 1 1
32 0 die "Color '$name' of theme $self->{orig_class} returns coderef, ".
33 "which after called still returns a coderef";
34 }
35 1 return $c2;
36 }
37 4 $c;
38 }
39  
40 4 1;
41 # ABSTRACT: Base class for color theme modules with static list of items (from %THEME)
42  
43 __END__
« ColorTheme/Test/Dynamic.pm ↑ Summary ColorThemeBase/Base.pm »