File Coverage

blib/lib/Data/HTML/Footer.pm
Criterion Covered Total %
statement 20 20 100.0
branch n/a
condition n/a
subroutine 6 6 100.0
pod 0 1 0.0
total 26 27 96.3


line stmt bran cond sub pod time code
1             package Data::HTML::Footer;
2              
3 9     9   289485 use strict;
  9         21  
  9         462  
4 9     9   78 use warnings;
  9         57  
  9         605  
5              
6 9     9   4667 use Mo qw(build default is);
  9         7475  
  9         55  
7 9     9   37884 use Mo::utils::CSS 0.07 qw(check_css_unit);
  9         252131  
  9         276  
8 9     9   7179 use Mo::utils::URI qw(check_location);
  9         895966  
  9         299  
9              
10             our $VERSION = 0.02;
11              
12             has author => (
13             is => 'ro',
14             );
15              
16             has author_url => (
17             is => 'ro',
18             );
19              
20             has copyright_years => (
21             is => 'ro',
22             );
23              
24             has height => (
25             is => 'ro',
26             );
27              
28             has version => (
29             is => 'ro',
30             );
31              
32             has version_url => (
33             is => 'ro',
34             );
35              
36             sub BUILD {
37 19     19 0 2415036 my $self = shift;
38              
39             # Check author_url.
40 19         125 check_location($self, 'author_url');
41              
42             # Check copyright years.
43             # TODO
44              
45             # Check height.
46 18         25608 check_css_unit($self, 'height');
47              
48             # Check version_url.
49 15         408 check_location($self, 'version_url');
50              
51 14         5319 return;
52             }
53              
54             1;
55              
56             __END__
57              
58             =pod
59              
60             =encoding utf8
61              
62             =head1 NAME
63              
64             Data::HTML::Footer - Data object for HTML footer.
65              
66             =head1 SYNOPSIS
67              
68             use Data::HTML::Footer;
69              
70             my $obj = Data::HTML::Footer->new(%params);
71             my $author = $obj->author;
72             my $author_url = $obj->author_url;
73             my $copyright_years = $obj->copyright_years;
74             my $height = $obj->height;
75             my $version = $obj->version;
76             my $version_url = $obj->version_url;
77              
78             =head1 METHODS
79              
80             =head2 C<new>
81              
82             my $obj = Data::HTML::Footer->new(%params);
83              
84             Constructor.
85              
86             =over 8
87              
88             =item * C<author>
89              
90             Author to present in footer.
91              
92             It's optional.
93              
94             Default value is undef.
95              
96             =item * C<author_url>
97              
98             Author absolute or relative URL.
99              
100             It's optional.
101              
102             Default value is undef.
103              
104             =item * C<copyright_years>
105              
106             Copyright years.
107              
108             It's optional.
109              
110             Default value is undef.
111              
112             =item * C<version>
113              
114             Version of application for present in footer.
115              
116             It's optional.
117              
118             Default value is undef.
119              
120             =item * C<version_url>
121              
122             Version absolute or relative URL.
123              
124             It's optional.
125              
126             Default value is undef.
127              
128             =back
129              
130             Returns instance of object.
131              
132             =head2 C<author>
133              
134             my $author = $obj->author;
135              
136             Get author string.
137              
138             Returns string.
139              
140             =head2 C<athor_url>
141              
142             my $author_url = $obj->author_url;
143              
144             Get author URL.
145              
146             Returns string.
147              
148             =head2 C<copyright_years>
149              
150             my $copyright_years = $obj->copyright_years;
151              
152             Get copyright years.
153              
154             Returns string.
155              
156             =head2 C<height>
157              
158             my $height = $obj->height;
159              
160             Get height of HTML footer.
161              
162             Returns CSS unit.
163              
164             =head2 C<version>
165              
166             my $version = $obj->version;
167              
168             Get version of application.
169              
170             Returns string.
171              
172             =head2 C<version_url>
173              
174             my $version_url = $obj->version_url;
175              
176             Get version URL.
177              
178             Returns string.
179              
180             =head1 ERRORS
181              
182             new():
183             From Mo::utils::CSS::check_css_unit():
184             Parameter 'height' contain bad unit.
185             Unit: %s
186             Value: %s
187             Parameter 'height' doesn't contain unit name.
188             Value: %s
189             Parameter 'height' doesn't contain unit number.
190             Value: %s
191             From Mo::utils::URI::check_location():
192             Parameter 'author_url' doesn't contain valid location.
193             Value: %s
194             Parameter 'version_url' doesn't contain valid location.
195             Value: %s
196              
197             =head1 EXAMPLE1
198              
199             =for comment filename=footer.pl
200              
201             use strict;
202             use warnings;
203              
204             use Data::HTML::Footer;
205              
206             my $obj = Data::HTML::Footer->new(
207             'author' => 'John',
208             'author_url' => 'https://example.com',
209             'copyright_years' => '2023-2024',
210             'height' => '40px',
211             'version' => 0.07,
212             'version_url' => '/changes',
213             );
214              
215             # Print out.
216             print 'Author: '.$obj->author."\n";
217             print 'Author URL: '.$obj->author_url."\n";
218             print 'Copyright years: '.$obj->copyright_years."\n";
219             print 'Footer height: '.$obj->height."\n";
220             print 'Version: '.$obj->version."\n";
221             print 'Version URL: '.$obj->version_url."\n";
222              
223             # Output:
224             # Author: John
225             # Author URL: https://example.com
226             # Copyright years: 2023-2024
227             # Footer height: 40px
228             # Version: 0.07
229             # Version URL: /changes
230              
231             =head1 DEPENDENCIES
232              
233             L<Mo>,
234             L<Mo::utils::CSS>,
235             L<Mo::utils::URI>.
236              
237             =head1 REPOSITORY
238              
239             L<https://github.com/michal-josef-spacek/Data-HTML-Footer>
240              
241             =head1 AUTHOR
242              
243             Michal Josef Špaček L<mailto:skim@cpan.org>
244              
245             L<http://skim.cz>
246              
247             =head1 LICENSE AND COPYRIGHT
248              
249             © 2024 Michal Josef Špaček
250              
251             BSD 2-Clause License
252              
253             =head1 VERSION
254              
255             0.02
256              
257             cut