Hotline/User.pm

filter: Statementstmt 26.6% 8 / 30 Branchbran 0.0% 0 / 16 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 22.2% 2 / 9 Podpod 100% 7 / 7 totaltotal 22.0% 17 / 77 CC 12 SCAR 22.1
CC
12
Cov
15%
new
12.0
socket
12.0
icon
12.0
CRAP 9.1
« Hotline/Shared.pm ↑ Summary Hotline/Task.pm »
1 package Net::Hotline::User;
2  
3 ## Copyright(c) 1998-2002 by John C. Siracusa. All rights reserved. This
4 ## program is free software; you can redistribute it and/or modify it under
5 ## the same terms as Perl itself.
6  
7 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 1 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 1 $VERSION = '0.80';
12  
13 sub new
14 0 ▶{
Subroutine new: not called CC=3 SCAR=24.8
Pod documented
15 0 my($class, @args) = @_;
16  
17 0 my($data) = join('', @args);
18  
19 0 my($self);
20  
21 0 ▶ if(@args == 5)
Branch: 2 branches
BranchTrueFalseTotal
if (@args == 5) { } 0 0 0
elsif (@args == 1) { } 0 0 0
22 {
23 0 $self =
24 {
25 'SOCKET' => $args[0],
26 'NICK' => $args[1],
27 'LOGIN' => $args[2],
28 'ICON' => $args[3],
29 'COLOR' => $args[4],
30 'INFO' => undef
31 };
32 }
33 elsif(@args == 1)
34 {
35 0 my($nick_len) = unpack("n", substr($data, 6, 2));
36  
37 0 $self =
38 {
39 'SOCKET' => unpack("n", substr($data, 0, 2)),
40 'ICON' => unpack("n", substr($data, 2, 2)),
41 'COLOR' => unpack("n", substr($data, 4, 2)),
42 'NICK' => join('', substr($data, 8, $nick_len)),
43 'LOGIN' => undef,
44 'INFO' => undef
45 };
46 }
47 else
48 {
49 0 $self =
50 {
51 'SOCKET' => undef,
52 'NICK' => undef,
53 'LOGIN' => undef,
54 'ICON' => undef,
55 'COLOR' => undef,
56 'INFO' => undef
57 };
58 }
59  
60 0 bless $self, $class;
61 0 return $self;
62 }
63  
64 sub socket
65 0 ▶{
Subroutine socket: not called CC=3 SCAR=24.8
Pod documented
66 0 ▶ $_[0]->{'SOCKET'} = $_[1] if(@_ > 1 && $_[1] =~ /^\d+$/);
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 and $_[1] =~ /^\d+$/ 0 0 0
Condition0%0/3
@_ > 1 and $_[1] =~ /^\d+$/
!ll&&!rl&&r
000
MC/DC0%0/2
@_ > 1 and $_[1] =~ /^\d+$/
@_ > 1 $_[1] =~ /^\d+$/
Truth table0%0/3
A and B
A= @_ > 1B= $_[1] =~ /^\d+$/
ABresult
0X0
100
111
67 0 return $_[0]->{'SOCKET'};
68 }
69  
70 sub nick
71 0 ▶{
Subroutine nick: not called CC=2 SCAR=17.9
Pod documented
72 0 ▶ $_[0]->{'NICK'} = $_[1] if(defined($_[1]));
Branch: 1 branch
BranchTrueFalseTotal
if defined $_[1] 0 0 0
73 0 return $_[0]->{'NICK'};
74 }
75  
76 sub login
77 0 ▶{
Subroutine login: not called CC=2 SCAR=17.9
Pod documented
78 0 ▶ $_[0]->{'LOGIN'} = $_[1] if(defined($_[1]));
Branch: 1 branch
BranchTrueFalseTotal
if defined $_[1] 0 0 0
79 0 return $_[0]->{'LOGIN'};
80 }
81  
82 sub icon
83 0 ▶{
Subroutine icon: not called CC=3 SCAR=24.8
Pod documented
84 0 ▶ $_[0]->{'ICON'} = $_[1] if(@_ > 1 && $_[1] =~ /^-?\d+$/);
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 and $_[1] =~ /^-?\d+$/ 0 0 0
Condition0%0/3
@_ > 1 and $_[1] =~ /^-?\d+$/
!ll&&!rl&&r
000
MC/DC0%0/2
@_ > 1 and $_[1] =~ /^-?\d+$/
@_ > 1 $_[1] =~ /^-?\d+$/
Truth table0%0/3
A and B
A= @_ > 1B= $_[1] =~ /^-?\d+$/
ABresult
0X0
100
111
85 0 return $_[0]->{'ICON'};
86 }
87  
88 sub color
89 0 ▶{
Subroutine color: not called CC=3 SCAR=24.8
Pod documented
90 0 ▶ $_[0]->{'COLOR'} = $_[1] if(@_ > 1 && $_[1] =~ /^\d+$/);
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 and $_[1] =~ /^\d+$/ 0 0 0
Condition0%0/3
@_ > 1 and $_[1] =~ /^\d+$/
!ll&&!rl&&r
000
MC/DC0%0/2
@_ > 1 and $_[1] =~ /^\d+$/
@_ > 1 $_[1] =~ /^\d+$/
Truth table0%0/3
A and B
A= @_ > 1B= $_[1] =~ /^\d+$/
ABresult
0X0
100
111
91 0 return $_[0]->{'COLOR'};
92 }
93  
94 sub info
95 0 ▶{
Subroutine info: not called CC=2 SCAR=17.9
Pod documented
96 0 ▶ $_[0]->{'INFO'} = $_[1] if(defined($_[1]));
Branch: 1 branch
BranchTrueFalseTotal
if defined $_[1] 0 0 0
97 0 return $_[0]->{'INFO'};
98 }
99  
100 1 1;
« Hotline/Shared.pm ↑ Summary Hotline/Task.pm »