blib/lib/WWW/Wookie/User.pm

filter: Statementstmt 100% 47 / 47 Branchbran 100% 4 / 4 Conditioncond 66.6% 4 / 6 MC/DCmcdc 50.0% 2 / 4 Subroutinesub 100% 12 / 12 Podpod n/a totaltotal 94.5% 69 / 73 CC 5 SCAR 8.2
CC
5
Cov
96%
__ANON__
5.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.3
« Build ↑ Summary blib/lib/WWW/Wookie/Server/Connection.pm »
1 package WWW::Wookie::User v1.1.1; # -*- cperl; cperl-indent-level: 4 -*-
2 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 5 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 5 ▶use 5.020000;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 5 ▶use Moose qw/around has/;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 5 ▶use Moose::Util::TypeConstraints qw/as coerce from where subtype via/;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 5 ▶use namespace::autoclean '-except' => 'meta', '-also' => qr/^_/sxm;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 5 ▶use Readonly;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 ## no critic qw(ProhibitCallsToUnexportedSubs)
14 5 Readonly::Scalar my $EMPTY => q{};
15 5 Readonly::Scalar my $UNKNOWN => q{UNKNOWN};
16 5 Readonly::Scalar my $MORE_ARGS => 3;
17 ## use critic
18  
19 44 ▶subtype 'Trimmed' => as 'Str' => where { m{(^$|(^\S|\S$))}gsmx };
Subroutine __ANON__: called CC=1 SCAR=0.0
20  
21 14 ▶coerce 'Trimmed' => from 'Str' => via { s{^\s+(.*)\s+$}{$1}gsmx; $_ };
Subroutine __ANON__: called CC=1 SCAR=0.0
22  
23 5 has 'loginName' => (
24 'is' => 'rw',
25 'isa' => 'Trimmed',
26 'coerce' => 1,
27 'default' => $UNKNOWN,
28 'reader' => 'getLoginName',
29 'writer' => 'setLoginName',
30 );
31  
32 5 has 'screenName' => (
33 'is' => 'rw',
34 'isa' => 'Trimmed',
35 'coerce' => 1,
36 'default' => $UNKNOWN,
37 'reader' => 'getScreenName',
38 'writer' => 'setScreenName',
39 );
40  
41 5 has 'thumbnailUrl' => (
42 'is' => 'ro',
43 'isa' => 'Str',
44 'default' => $EMPTY,
45 'reader' => 'getThumbnailUrl',
46 'writer' => 'setThumbnailUrl',
47 );
48  
49 around 'BUILDARGS' => sub {
50 11 ▶ my $orig = shift;
Subroutine __ANON__: called CC=5 SCAR=16.2
51 11 my $class = shift;
52  
53 11 ▶ if ( 2 == @_ && !ref $_[0] ) {
Branch: 1 branch
BranchTrueFalseTotal
if (2 == @_ and not ref $_[0]) 7 4 11
Condition66%2/3
2 == @_ and not ref $_[0]
!ll&&!rl&&r
407
MC/DC50%1/2
2 == @_ and not ref $_[0]
2 == @_ not ref $_[0]
Truth table66%2/3
A and not(B)
A= 2 == @_B= not ref $_[0]
ABresult
0X0
100
111
54 7 push @_, $EMPTY;
55 }
56 11 ▶ if ( @_ == $MORE_ARGS && !ref $_[0] ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == $MORE_ARGS and not ref $_[0]) 7 4 11
Condition66%2/3
@_ == $MORE_ARGS and not ref $_[0]
!ll&&!rl&&r
407
MC/DC50%1/2
@_ == $MORE_ARGS and not ref $_[0]
@_ == $MORE_ARGS not ref $_[0]
Truth table66%2/3
A and not(B)
A= @_ == $MORE_ARGSB= not ref $_[0]
ABresult
0X0
100
111
57 7 return $class->$orig(
58 'loginName' => $_[0],
59 'screenName' => $_[1],
60 'thumbnailUrl' => $_[2],
61 );
62 }
63 4 return $class->$orig(@_);
64 5 };
65  
66 5 ▶no Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
67  
68 5 __PACKAGE__->meta->make_immutable;
69  
70 5 1;
71  
72 __END__
73  
74 =encoding utf8
75  
76 =for stopwords url Readonly Ipenburg login MERCHANTABILITY
77  
78 =head1 NAME
79  
80 WWW::Wookie::User - represent a possible user of a widget
81  
82 =head1 VERSION
83  
84 This document describes WWW::Wookie::User version v1.1.1
85  
86 =head1 SYNOPSIS
87  
88 use WWW::Wookie::User;
89 $u = WWW::Wookie::User->new($login, $nick);
90  
91 =head1 DESCRIPTION
92  
93 A user represents a possible user of a widget. This class provides a standard
94 way of representing users in plugins for host environments.
95  
96 =head1 SUBROUTINES/METHODS
97  
98 =head2 C<new>
99  
100 Create a new user.
101  
102 =over
103  
104 =item 1. User login name as string
105  
106 =item 2. User display name as string
107  
108 =item 3. Optional thumbnail URL as string
109  
110 =back
111  
112 =head2 C<getLoginName>
113  
114 Get the login name for this user. Returns the user login name as string.
115  
116 =head2 C<getScreenName>
117  
118 Get the screen name for this user. This is the name that is intended to be
119 displayed on screen. In many cases it will be the same as the login name.
120 Returns the user display name as a string.
121  
122 =head2 C<setLoginName>
123  
124 Set the login name for this user. this is the value that is used by the user
125 to register on the system, it is guaranteed to be unique.
126  
127 =over
128  
129 =item 1. New login name as string
130  
131 =back
132  
133 =head2 C<setScreenName>
134  
135 Set the screen name for this user. This is the value that should be displayed
136 on screen. In many cases it will be the same as the login name.
137  
138 =over
139  
140 =item 1. New screen name as string
141  
142 =back
143  
144 =head2 C<getThumbnailUrl>
145  
146 Get the URL for a thumbnail representing this user. Returns the user thumbnail
147 icon url as string.
148  
149 =head2 C<setThumbnailUrl>
150  
151 Set the URL for a thumbnail representing this user.
152  
153 =over
154  
155 =item 1. New thumbnail URL as string
156  
157 =back
158  
159 =head1 CONFIGURATION AND ENVIRONMENT
160  
161 =head1 DEPENDENCIES
162  
163 =over 4
164  
165 =item * L<Moose|Moose>
166  
167 =item * L<Moose::Util::TypeConstraints|Moose::Util::TypeConstraints>
168  
169 =item * L<Readonly|Readonly>
170  
171 =item * L<namespace::autoclean|namespace::autoclean>
172  
173 =back
174  
175 =head1 INCOMPATIBILITIES
176  
177 =head1 DIAGNOSTICS
178  
179 =head1 BUGS AND LIMITATIONS
180  
181 Please report any bugs or feature requests at L<RT for
182 rt.cpan.org|https://rt.cpan.org/Dist/Display.html?Queue=WWW-Wookie>.
183  
184 =head1 AUTHOR
185  
186 Roland van Ipenburg, E<lt>ipenburg@xs4all.nlE<gt>
187  
188 =head1 LICENSE AND COPYRIGHT
189  
190 Copyright 2017 by Roland van Ipenburg
191  
192 This library is free software; you can redistribute it and/or modify
193 it under the same terms as Perl itself, either Perl version 5.14.0 or,
194 at your option, any later version of Perl 5 you may have available.
195  
196 =head1 DISCLAIMER OF WARRANTY
197  
198 BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
199 FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
200 OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
201 PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
202 EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
203 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE
204 ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH
205 YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL
206 NECESSARY SERVICING, REPAIR, OR CORRECTION.
207  
208 IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
209 WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
210 REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENSE, BE
211 LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL,
212 OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE
213 THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
214 RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
215 FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
216 SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
217 SUCH DAMAGES.
218  
219 =cut
« Build ↑ Summary blib/lib/WWW/Wookie/Server/Connection.pm »