blib/lib/Date/Holidays/Adapter/CZ.pm

filter: Statementstmt 43.2% 16 / 37 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 57.1% 4 / 7 Podpod 100% 2 / 2 totaltotal 44.0% 22 / 50 CC 4 SCAR 13.9
CC
4
Cov
39%
holidays
6.0
is_holiday
6.0
_transform_arrayref_to_hashref
6.0
CRAP 4.0
« blib/lib/Date/Holidays/Adapter/DE.pm ↑ Summary blib/lib/Date/Holidays/Adapter/AW.pm »
1 package Date::Holidays::Adapter::CZ;
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  
6 1 ▶use base 'Date::Holidays::Adapter';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 $VERSION = '1.35';
11  
12 1 my $format = '%#:%m%d';
13  
14 # Lifted from Date::Holidays::CZ example: svatky.plx
15 # Ref: https://metacpan.org/source/SMITHFARM/Date-Holidays-CZ-0.13/example/svatky.plx
16 1 my %holiday_names = (
17 'obss' => 'Restoration Day of the Independent Czech State',
18 'veln' => 'Easter Sunday',
19 'velp' => 'Easter Monday',
20 'svpr' => 'Labor Day',
21 'dvit' => 'Liberation Day',
22 'cyme' => 'Saints Cyril and Methodius Day',
23 'mhus' => 'Jan Hus Day',
24 'wenc' => 'Feast of St. Wenceslas (Czech Statehood Day)',
25 'vzcs' => 'Independent Czechoslovak State Day',
26 'bojs' => 'Struggle for Freedom and Democracy Day',
27 'sted' => 'Christmas Eve',
28 'van1' => 'Christmas Day',
29 'van2' => 'Feast of St. Stephen',
30 );
31  
32 0 ▶sub holidays {
Subroutine holidays: not called CC=2 SCAR=17.9
Pod documented
33 0 my ($self, %params) = @_;
34  
35 0 my $sub = $self->{_adaptee}->can('holidays');
36  
37 0 ▶ if ($sub) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sub) { } 0 0 0
38 0 return &{$sub}(YEAR => $params{'year'});
39 } else {
40 0 return {};
41 }
42 }
43  
44 0 ▶sub is_holiday {
Subroutine is_holiday: not called CC=2 SCAR=17.9
Pod documented
45 0 my ($self, %params) = @_;
46  
47 my $holidays = Date::Holidays::CZ::holidays(
48 0 YEAR => $params{'year'},
49 FORMAT => $format,
50 );
51  
52 0 my $holidays_hashref = $self->_transform_arrayref_to_hashref($holidays);
53  
54 0 my $holiday_date = sprintf('%02s%02s', $params{month}, $params{day});
55  
56 0 my $holiday = $holidays_hashref->{$holiday_date};
57  
58 0 ▶ if ($holiday) {
Branch: 1 branch
BranchTrueFalseTotal
if ($holiday) { } 0 0 0
59 0 return $holiday;
60 } else {
61 0 return '';
62 }
63 }
64  
65 0 ▶sub _transform_arrayref_to_hashref {
Subroutine _transform_arrayref_to_hashref: not called CC=2 SCAR=17.9
66 0 my ($self, $arrayref_of_holidays) = @_;
67  
68 0 my $hashref_of_holidays;
69  
70 0 foreach my $entry (@{$arrayref_of_holidays}) {
71 0 my ($shortname, $key) = split /:/, $entry;
72 0 $hashref_of_holidays->{$key} = $holiday_names{$shortname};
73 }
74  
75 0 return $hashref_of_holidays;
76 }
77  
78 1 1;
79  
80 __END__
« blib/lib/Date/Holidays/Adapter/DE.pm ↑ Summary blib/lib/Date/Holidays/Adapter/AW.pm »