File Coverage

blib/lib/Toolforge/MixNMatch/Object/YearMonth.pm
Criterion Covered Total %
statement 17 17 100.0
branch n/a
condition n/a
subroutine 5 5 100.0
pod 0 1 0.0
total 22 23 95.6


line stmt bran cond sub pod time code
1             package Toolforge::MixNMatch::Object::YearMonth;
2              
3 6     6   864098 use strict;
  6         15  
  6         239  
4 6     6   32 use warnings;
  6         13  
  6         355  
5              
6 6     6   3193 use Mo qw(build is);
  6         4271  
  6         36  
7 6     6   15118 use Mo::utils qw(check_required);
  6         121898  
  6         182  
8              
9             our $VERSION = 0.04;
10              
11             has count => (
12             is => 'ro',
13             required => 1,
14             );
15              
16             has month => (
17             is => 'ro',
18             required => 1,
19             );
20              
21             has year => (
22             is => 'ro',
23             required => 1,
24             );
25              
26             sub BUILD {
27 4     4 0 847729 my $self = shift;
28              
29 4         30 check_required($self, 'count');
30 4         70 check_required($self, 'month');
31 4         37 check_required($self, 'year');
32              
33 4         40 return;
34             }
35              
36             1;
37              
38             __END__
39              
40             =pod
41              
42             =encoding utf8
43              
44             =head1 NAME
45              
46             Toolforge::MixNMatch::Object::YearMonth - Mix'n'match year/month datatype.
47              
48             =head1 SYNOPSIS
49              
50             use Toolforge::MixNMatch::Object::YearMonth;
51              
52             my $obj = Toolforge::MixNMatch::Object::YearMonth->new(%params);
53             my $count = $obj->count;
54             my $month = $obj->month;
55             my $year = $obj->year;
56              
57             =head1 DESCRIPTION
58              
59             This datatype is base class for Mix'n'match year/month.
60              
61             =head1 METHODS
62              
63             =head2 C<new>
64              
65             my $obj = Toolforge::MixNMatch::Object::YearMonth->new(%params);
66              
67             Constructor.
68              
69             Returns instance of object.
70              
71             =over 8
72              
73             =item * C<count>
74              
75             Count number of records for user.
76             Parameter is required.
77              
78             =item * C<month>
79              
80             Month of statistics.
81             Parameter is required.
82              
83             =item * C<year>
84              
85             Year of statistics.
86             Parameter is required.
87              
88             =back
89              
90             =head2 C<count>
91              
92             my $count = $obj->count;
93              
94             Get count for year/month statistics.
95              
96             Returns number.
97              
98             =head2 C<month>
99              
100             my $month = $obj->month;
101              
102             Get month of statistics.
103              
104             Returns number.
105              
106             =head2 C<year>
107              
108             my $year = $obj->year;
109              
110             Get year of statistics.
111              
112             Returns number.
113              
114             =head1 ERRORS
115              
116             new():
117             From Mo::utils::check_required():
118             Parameter 'count' is required.
119             Parameter 'month' is required.
120             Parameter 'year' is required.
121              
122             =head1 EXAMPLE
123              
124             =for comment filename=create_year_month_and_print_out.pl
125              
126             use strict;
127             use warnings;
128              
129             use Toolforge::MixNMatch::Object::YearMonth;
130              
131             # Object.
132             my $obj = Toolforge::MixNMatch::Object::YearMonth->new(
133             'count' => 6,
134             'month' => 1,
135             'year' => 2020,
136             );
137              
138             # Get count for year/month statistics.
139             my $count = $obj->count;
140              
141             # Get month of statistics.
142             my $month = $obj->month;
143              
144             # Get year of statistics.
145             my $year = $obj->year;
146              
147             # Print out.
148             print "Count: $count\n";
149             print "Month: $month\n";
150             print "Year: $year\n";
151              
152             # Output:
153             # Count: 6
154             # Month: 1
155             # Year: 2020
156              
157             =head1 DEPENDENCIES
158              
159             L<Mo>,
160             L<Mo::utils>.
161              
162             =head1 SEE ALSO
163              
164             =over
165              
166             =item L<Toolforge::MixNMatch::Object>
167              
168             Toolforge Mix'n'match tool objects.
169              
170             =back
171              
172             =head1 REPOSITORY
173              
174             L<https://github.com/michal-josef-spacek/Toolforge-MixNMatch-Object>
175              
176             =head1 AUTHOR
177              
178             Michal Josef Špaček L<mailto:skim@cpan.org>
179              
180             L<http://skim.cz>
181              
182             =head1 LICENSE AND COPYRIGHT
183              
184             © Michal Josef Špaček 2020-2025
185              
186             BSD 2-Clause License
187              
188             =head1 VERSION
189              
190             0.04
191              
192             =cut