examples/HTTP/API/Core/Example/GitHub.pm

filter: Statementstmt 100% 27 / 27 Branchbran 50.0% 2 / 4 Conditioncond 57.1% 4 / 7 MC/DCmcdc 25.0% 1 / 4 Subroutinesub 100% 7 / 7 Podpod 50.0% 1 / 2 totaltotal 82.3% 42 / 51 CC 8 SCAR 10.3
CC
8
Cov
87%
__ANON__
4.0
new
3.3
repositories_pager
3.0
CRAP 2.8
« examples/HTTP/API/Core/Example/Stripe.pm ↑ Summary examples/HTTP/API/Core/Example/GitLab.pm »
1 package HTTP::API::Core::Example::GitHub;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use parent 'HTTP::API::Core';
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 ▶sub new {
Subroutine new: called CC=3 SCAR=12.0
Pod documented
8 1 my ($class, %args) = @_;
9 1 my $token = delete $args{token};
10 1 ▶ die "token is required\n" if !defined($token) || $token eq '';
Branch: 1 branch
BranchTrueFalseTotal
if not defined $token or $token eq "" 0 1 1
Condition33%1/3
not defined $token or $token eq ""
l!l&&r!l&&!r
001
MC/DC0%0/2
not defined $token or $token eq ""
not defined $token $token eq ""
Truth table33%1/3
not(A) or B
A= not defined $tokenB= $token eq ""
ABresult
1X1
011
000
11  
12 1 return $class->SUPER::new(
13 base_url => 'https://api.github.com',
14 headers => {
15 Accept => 'application/vnd.github+json',
16 Authorization => "Bearer $token",
17 'X-GitHub-Api-Version' => '2026-03-10',
18 },
19 %args,
20 );
21 }
22  
23 1 ▶sub repositories_pager {
Subroutine repositories_pager: called CC=3 SCAR=11.0
Pod undocumented
24 1 my ($self, %args) = @_;
25 1 ▶ my $per_page = delete($args{per_page}) || 100;
Condition50%1/2
delete $args{'per_page'} || 100
l!l
10
MC/DC0%0/1
delete $args{'per_page'} || 100
delete $args{'per_page'}
Truth table50%1/2
A
A= delete $args{'per_page'}
Aresult
11
00
26 1 my $affiliation = delete $args{affiliation};
27 1 my $sort = delete $args{sort};
28 1 my $direction = delete $args{direction};
29 1 die "unknown repositories option: $_\n" for sort keys %args;
30  
31 return $self->paginate(
32 '/user/repos',
33 mode => 'next_url',
34 response_aware_extractors => 1,
35 2 ▶ items => sub { return $_[0] },
Subroutine __ANON__: called CC=1 SCAR=0.0
36 2 ▶ next => sub {
Subroutine __ANON__: called CC=4 SCAR=13.9
37 2 my ($data, $response) = @_;
38 2 ▶ my $link = $response->header('link') || '';
Condition100%2/2
$response->header('link') || ''
l!l
11
MC/DC100%1/1
$response->header('link') || ''
$response->header('link')
Truth table100%2/2
A
A= $response->header('link')
Aresult
11
00
39 2 for my $part (split /,\s*/, $link) {
40 1 ▶ return $1 if $part =~ /<([^>]+)>;\s*rel="next"/;
Branch: 1 branch
BranchTrueFalseTotal
if $part =~ /<([^>]+)>;\s*rel="next"/ 1 0 1
41 }
42 1 return undef;
43 },
44 1 query => {
45 per_page => $per_page,
46 affiliation => $affiliation,
47 sort => $sort,
48 direction => $direction,
49 },
50 );
51 }
52  
53 1 1;
« examples/HTTP/API/Core/Example/Stripe.pm ↑ Summary examples/HTTP/API/Core/Example/GitLab.pm »