Component/Controller/History.pm

filter: Statementstmt 100% 33 / 33 Branchbran 75.0% 3 / 4 Conditioncond 50.0% 3 / 6 MC/DCmcdc 25.0% 1 / 4 Subroutinesub 100% 9 / 9 Podpod 100% 6 / 6 totaltotal 88.7% 55 / 62 CC 5 SCAR 5.8
CC
5
Cov
91%
latest
3.0
new
2.1
count
2.0
CRAP 1.8
« Component.pm ↑ Summary
1 package Games::Sudoku::Component::Controller::History;
2 {
3 4 ▶ use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶ use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 ▶ use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
6
7 4 our $VERSION = '0.01';
8
9 7 ▶ sub new {
Subroutine new: called CC=2 SCAR=7.4
Pod documented
10 7 my $class = shift;
11 7 ▶ my $this = bless {}, (ref $class || $class);
Condition33%1/3
ref $class || $class
l!l&&r!l&&!r
070
MC/DC0%0/2
ref $class || $class
ref $class $class
Truth table33%1/3
A || B
A= ref $classB= $class
ABresult
1X1
011
000
12
13 7 $this->{history} = [];
14
15 7 $this;
16 }
17
18 314 ▶ sub push {
Subroutine push: called CC=1 SCAR=0.0
Pod documented
19 314 my ($this, $item) = @_;
20 314 push @{ $this->{history} }, $item;
21 }
22
23 57 ▶ sub pop {
Subroutine pop: called CC=1 SCAR=0.0
Pod documented
24 57 my $this = shift;
25 57 pop @{ $this->{history} };
26 }
27
28 6 ▶ sub clear {
Subroutine clear: called CC=1 SCAR=0.0
Pod documented
29 6 my $this = shift;
30 6 $this->{history} = [];
31 }
32
33 7 ▶ sub count {
Subroutine count: called CC=2 SCAR=7.0
Pod documented
34 7 my $this = shift;
35
36 7 ▶ return 0 unless defined $this->{history};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $this->{"history"} 0 7 7
37
38 7 scalar @{ $this->{history} };
39 }
40
41 7 ▶ sub latest {
Subroutine latest: called CC=3 SCAR=11.0
Pod documented
42 7 my ($this, $count) = @_;
43
44 7 my @history = @{ $this->{history} };
45
46 7 ▶ $count = @history if !$count || $count > @history;
Branch: 1 branch
BranchTrueFalseTotal
if not $count or $count > @history 6 1 7
Condition66%2/3
not $count or $count > @history
l!l&&r!l&&!r
601
MC/DC50%1/2
not $count or $count > @history
not $count $count > @history
Truth table66%2/3
not(A) or B
A= not $countB= $count > @history
ABresult
1X1
011
000
47
48 7 my @latest = reverse @history[-$count..-1];
49 }
50 }
51
52 4 1;
53 __END__
« Component.pm ↑ Summary