File Coverage

blib/lib/Toolforge/MixNMatch/Object/User.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::User;
2              
3 6     6   795525 use strict;
  6         14  
  6         225  
4 6     6   31 use warnings;
  6         10  
  6         398  
5              
6 6     6   2575 use Mo qw(build is);
  6         3554  
  6         35  
7 6     6   14376 use Mo::utils qw(check_required);
  6         92211  
  6         136  
8              
9             our $VERSION = 0.04;
10              
11             has count => (
12             is => 'ro',
13             required => 1,
14             );
15              
16             has uid => (
17             is => 'ro',
18             required => 1,
19             );
20              
21             has username => (
22             is => 'ro',
23             required => 1,
24             );
25              
26             sub BUILD {
27 7     7 0 857455 my $self = shift;
28              
29 7         44 check_required($self, 'count');
30 6         84 check_required($self, 'uid');
31 5         41 check_required($self, 'username');
32              
33 4         35 return;
34             }
35              
36             1;
37              
38             __END__
39              
40             =pod
41              
42             =encoding utf8
43              
44             =head1 NAME
45              
46             Toolforge::MixNMatch::Object::User - Mix'n'match user datatype.
47              
48             =head1 SYNOPSIS
49              
50             use Toolforge::MixNMatch::Object::User;
51              
52             my $obj = Toolforge::MixNMatch::Object::User->new(%params);
53             my $count = $obj->count;
54             my $uid = $obj->uid;
55             my $username = $obj->username;
56              
57             =head1 DESCRIPTION
58              
59             This datatype is base class for Mix'n'match user.
60              
61             =head1 METHODS
62              
63             =head2 C<new>
64              
65             my $obj = Toolforge::MixNMatch::Object::User->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<uid>
79              
80             User UID.
81             Parameter is required.
82              
83             =item * C<username>
84              
85             User name.
86             Parameter is required.
87              
88             =back
89              
90             =head2 C<count>
91              
92             my $count = $obj->count;
93              
94             Get count for user.
95              
96             Returns number.
97              
98             =head2 C<uid>
99              
100             my $uid = $obj->uid;
101              
102             Get UID of user.
103              
104             Returns number.
105              
106             =head2 C<username>
107              
108             my $username = $obj->username;
109              
110             Get user name.
111              
112             Returns string.
113              
114             =head1 ERRORS
115              
116             new():
117             From Mo::utils::check_required():
118             Parameter 'count' is required.
119             Parameter 'uid' is required.
120             Parameter 'username' is required.
121              
122             =head1 EXAMPLE
123              
124             =for comment filename=create_user_and_print_out.pl
125              
126             use strict;
127             use warnings;
128              
129             use Toolforge::MixNMatch::Object::User;
130              
131             # Object.
132             my $obj = Toolforge::MixNMatch::Object::User->new(
133             'count' => 6,
134             'uid' => 1,
135             'username' => 'Skim',
136             );
137              
138             # Get count for user.
139             my $count = $obj->count;
140              
141             # Get UID of user.
142             my $uid = $obj->uid;
143              
144             # Get user name.
145             my $username = $obj->username;
146              
147             # Print out.
148             print "Count: $count\n";
149             print "UID: $uid\n";
150             print "User name: $username\n";
151              
152             # Output:
153             # Count: 6
154             # UID: 1
155             # User name: Skim
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