| 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
MC/DC0%0/2
ref $class || $class
ref $class
$class
Truth table33%1/3
A || B
A= ref $classB= $class
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
Condition66%2/3
not $count or $count > @history
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
| |||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 7 | my @latest = reverse @history[-$count..-1]; | |||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 4 | 1; | |||||||||||||||||||||||||||
| 53 | __END__ | ||||||||||||||||||||||||||||