| 1 | 10 | ▶ | use v5.36; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 2 | 10 | ▶ | use feature 'class'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 10 | ▶ | no warnings 'experimental::class'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 10 | ▶ | use Azure::SDK::Core::Page; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 10 | class Azure::SDK::Core::Pager { | |||||||||||||||||||||||||||
| 8 | 10 | ▶ | use Carp qw(croak); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 10 | ▶ | use Scalar::Util qw(blessed); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 10 | field $fetch_page :param; | |||||||||||||||||||||||||||
| 12 | 10 | field $continuation_token :param :reader = undef; | |||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 10 | field $current_page :reader = undef; | |||||||||||||||||||||||||||
| 15 | 10 | field $item_index = 0; | |||||||||||||||||||||||||||
| 16 | 10 | field $exhausted = 0; | |||||||||||||||||||||||||||
| 17 | 10 | field %seen_tokens; | |||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 13 | ▶ | ADJUST { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=16.8
| |||||||||||||||||||||||||||||
| 20 | 13 | ▶ | croak 'Azure::SDK::Core::Pager fetch_page must be a code reference' | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 21 | unless ref $fetch_page eq 'CODE'; | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 13 | ▶ | $continuation_token = undef | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $continuation_token and not length $continuation_token
MC/DC0%0/2
defined $continuation_token and not length $continuation_token
defined $continuation_token
not length $continuation_token
Truth table66%2/3
A and not(B)
A= defined $continuation_tokenB= not length $continuation_token
| |||||||||||||||||||||||||||||
| 24 | if defined $continuation_token && !length $continuation_token; | ||||||||||||||||||||||||||||
| 25 | 13 | ▶ | $seen_tokens{$continuation_token} = 1 | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 26 | if defined $continuation_token; | ||||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | 3 | ▶ | method has_more () { | ||||||||||||||||||||||||||
|
Subroutine
has_more: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 30 | 3 | ▶ | return $exhausted ? 0 : 1; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 1 | ▶ | method items () { | ||||||||||||||||||||||||||
|
Subroutine
items: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||||||||||
| 34 | 1 | ▶ | return $current_page ? $current_page->items : []; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 26 | ▶ | method next_page () { | ||||||||||||||||||||||||||
|
Subroutine
next_page: called CC=7 SCAR=19.6
Pod
documented
| |||||||||||||||||||||||||||||
| 38 | 26 | ▶ | return undef if $exhausted; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 25 | my $page = $fetch_page->($continuation_token); | |||||||||||||||||||||||||||
| 41 | 25 | ▶ | croak 'Azure::SDK::Core::Pager fetch_page must return an Azure::SDK::Core::Page' | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
builtin::blessed($page) and $page->isa("Azure::SDK::Core::Page")
MC/DC0%0/2
builtin::blessed($page) and $page->isa("Azure::SDK::Core::Page")
builtin::blessed($page)
$page->isa("Azure::SDK::Core::Page")
Truth table33%1/3
A and B
A= builtin::blessed($page)B= $page->isa("Azure::SDK::Core::Page")
| |||||||||||||||||||||||||||||
| 42 | unless blessed($page) | ||||||||||||||||||||||||||||
| 43 | && $page->isa('Azure::SDK::Core::Page'); | ||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | 25 | $current_page = $page; | |||||||||||||||||||||||||||
| 46 | 25 | $item_index = 0; | |||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 25 | my $next_token = $page->continuation_token; | |||||||||||||||||||||||||||
| 49 | 25 | ▶ | if (defined $next_token && $seen_tokens{$next_token}++) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $next_token and $seen_tokens{$next_token}++
MC/DC100%2/2
defined $next_token and $seen_tokens{$next_token}++
defined $next_token
$seen_tokens{$next_token}++
Truth table100%3/3
A and B
A= defined $next_tokenB= $seen_tokens{$next_token}++
| |||||||||||||||||||||||||||||
| 50 | 1 | $continuation_token = $next_token; | |||||||||||||||||||||||||||
| 51 | 1 | $exhausted = 1; | |||||||||||||||||||||||||||
| 52 | 1 | croak 'Page listing returned a repeated continuation token'; | |||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 24 | $continuation_token = $next_token; | |||||||||||||||||||||||||||
| 56 | 24 | ▶ | $exhausted = 1 unless defined $continuation_token; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | 24 | return $page; | |||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | 31 | ▶ | method next_item () { | ||||||||||||||||||||||||||
|
Subroutine
next_item: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||
| 62 | 31 | while (1) { | |||||||||||||||||||||||||||
| 63 | 53 | ▶ | if ($current_page && $item_index < $current_page->count) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$current_page and $item_index < $current_page->count
MC/DC100%2/2
$current_page and $item_index < $current_page->count
$current_page
$item_index < $current_page->count
Truth table100%3/3
A and B
A= $current_pageB= $item_index < $current_page->count
| |||||||||||||||||||||||||||||
| 64 | 20 | return $current_page->items->[$item_index++]; | |||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | 33 | ▶ | return undef if $exhausted; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 68 | 22 | $self->next_page; | |||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 10 | 1; | |||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | __END__ | ||||||||||||||||||||||||||||