line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package UseCase::User; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
27
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
5
|
use List::Util qw(max); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
375
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# Storage |
9
|
|
|
|
|
|
|
my %USERS = ( |
10
|
|
|
|
|
|
|
1 => { |
11
|
|
|
|
|
|
|
name => 'Darth Wader', |
12
|
|
|
|
|
|
|
password => 'empire', |
13
|
|
|
|
|
|
|
email => 'darth@deathstar.com', |
14
|
|
|
|
|
|
|
}, |
15
|
|
|
|
|
|
|
2 => { |
16
|
|
|
|
|
|
|
name => 'Luke Skywalker', |
17
|
|
|
|
|
|
|
password => 'qwerty', |
18
|
|
|
|
|
|
|
email => 'l.skywalker@jedi.com', |
19
|
|
|
|
|
|
|
}, |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub list { |
23
|
3
|
|
|
3
|
0
|
11
|
my %params = @_; |
24
|
3
|
|
|
|
|
25
|
map { { id => $_, %{ $USERS{$_} } } } sort { $a <=> $b } keys %USERS; |
|
7
|
|
|
|
|
13
|
|
|
7
|
|
|
|
|
40
|
|
|
5
|
|
|
|
|
20
|
|
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub create { |
28
|
1
|
|
|
1
|
0
|
5
|
my %params = @_; |
29
|
|
|
|
|
|
|
|
30
|
1
|
|
|
|
|
8
|
my $id = max(keys %USERS) + 1; |
31
|
1
|
|
|
|
|
4
|
$USERS{$id} = \%params; |
32
|
|
|
|
|
|
|
|
33
|
1
|
|
|
|
|
17
|
$id; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub show { |
37
|
2
|
|
|
2
|
0
|
7
|
my $id = shift; |
38
|
2
|
|
|
|
|
8
|
$USERS{$id}; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub edit { |
42
|
2
|
|
|
2
|
0
|
10
|
my ($id, %params) = @_; |
43
|
|
|
|
|
|
|
|
44
|
2
|
|
|
|
|
7
|
foreach my $p (keys %params) { |
45
|
4
|
50
|
|
|
|
13
|
next unless $params{$p}; |
46
|
4
|
|
|
|
|
11
|
$USERS{$id}{$p} = $params{$p}; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
2
|
|
|
|
|
10
|
$USERS{$id}; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub remove { |
53
|
1
|
|
|
1
|
0
|
4
|
my $id = shift; |
54
|
1
|
|
|
|
|
4
|
delete $USERS{$id}; |
55
|
1
|
|
|
|
|
5
|
1; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub bump { |
59
|
1
|
|
|
1
|
0
|
4
|
my $id = shift; |
60
|
1
|
|
|
|
|
6
|
++$USERS{$id}{bumped}; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
1; |