« Twilio/Jwt/Validation/ClientValidationJwt.pm
↑ Summary
Twilio/Exceptions/TwilioServiceException.pm »
| 1 | package Twilio::Metadata; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use 5.016; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | 3 | ▶ | use Carp qw(croak); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | 3 | our $VERSION = '2.001'; | |||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||
| 10 | # read returns a list, so its records are kept in an array reference. | ||||||||||||||||||||||||||||||||||||||||||
| 11 | 3 | my %RETURNS_LIST = (read => 1); | |||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||
| 13 | 19 | ▶ | sub capture { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
capture: called CC=7 SCAR=19.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 19 | my ($class, $resource, $operation, @arguments) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||
| 16 | 19 | ▶ | if (!defined $operation || !length $operation) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $operation and length $operation
MC/DC100%2/2
defined $operation and length $operation
defined $operation
length $operation
Truth table100%3/3
A and B
A= defined $operationB= length $operation
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | 2 | croak 'with_metadata needs the name of an operation, such as fetch, create or read'; | |||||||||||||||||||||||||||||||||||||||||
| 18 | } | ||||||||||||||||||||||||||||||||||||||||||
| 19 | 17 | ▶ | if ($operation =~ /\A_/ || $operation eq 'with_metadata' || !$resource->can($operation)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$operation =~ /\A_/u or $operation eq "with_metadata" or not $resource->can($operation)
$operation =~ /\A_/u or $operation eq "with_metadata"
MC/DC100%3/3
$operation =~ /\A_/u or $operation eq "with_metadata" or not $resource->can($operation)
$operation =~ /\A_/u
$operation eq "with_metadata"
not $resource->can($operation)
Truth table100%4/4
A or B or not(C)
A= $operation =~ /\A_/uB= $operation eq "with_metadata"C= not $resource->can($operation)
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | 3 | croak 'with_metadata cannot call ' . ref($resource) . "->$operation"; | |||||||||||||||||||||||||||||||||||||||||
| 21 | } | ||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | 14 | my $client = $resource->{version}->get_domain->get_client; | |||||||||||||||||||||||||||||||||||||||||
| 24 | my ($data, @responses) = $client->capture_responses( | ||||||||||||||||||||||||||||||||||||||||||
| 25 | 14 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | 14 | ▶ | return $RETURNS_LIST{$operation} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 27 | ? [$resource->$operation(@arguments)] | ||||||||||||||||||||||||||||||||||||||||||
| 28 | : scalar $resource->$operation(@arguments); | ||||||||||||||||||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||||||||||||||||
| 30 | 14 | ); | |||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||
| 32 | # The first answer, as in twilio-php: a read's first page, or the one answer of the others. | ||||||||||||||||||||||||||||||||||||||||||
| 33 | 13 | my ($response) = @responses; | |||||||||||||||||||||||||||||||||||||||||
| 34 | 13 | ▶ | croak "$operation made no request to Twilio, so there is no answer to describe" if !$response; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 35 | 12 | return $class->new($data, $response->get_status_code, $response->get_headers); | |||||||||||||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||
| 38 | 14 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 39 | 14 | my ($class, $data, $status_code, $headers) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 40 | 14 | ▶ | return bless { data => $data, status_code => $status_code, headers => $headers // {} }, $class; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$headers // {}
MC/DC100%1/1
$headers // {}
$headers
Truth table100%2/2
A
A= $headers
| |||||||||||||||||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||
| 43 | 13 | ▶ | sub get_data { return $_[0]{data} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_data: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 44 | 5 | ▶ | sub get_status_code { return $_[0]{status_code} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_status_code: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 45 | 2 | ▶ | sub get_headers { return $_[0]{headers} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_headers: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||
| 47 | 14 | ▶ | sub get_header { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_header: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 48 | 14 | my ($self, $name) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 49 | 14 | ▶ | my $wanted = lc($name // q{}); | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$name // ""
MC/DC100%1/1
$name // ""
$name
Truth table100%2/2
A
A= $name
| |||||||||||||||||||||||||||||||||||||||||||
| 50 | 14 | my ($key) = grep { lc eq $wanted } sort keys %{ $self->{headers} }; | |||||||||||||||||||||||||||||||||||||||||
| 51 | 14 | ▶ | return if !defined $key; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||
| 53 | # A header sent more than once comes as a list; RFC 9110 joins those with commas. | ||||||||||||||||||||||||||||||||||||||||||
| 54 | 12 | my $value = $self->{headers}{$key}; | |||||||||||||||||||||||||||||||||||||||||
| 55 | 12 | ▶ | return ref $value eq 'ARRAY' ? join(', ', @{$value}) : $value; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||
| 58 | 3 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||
| 60 | __END__ | ||||||||||||||||||||||||||||||||||||||||||