Discord/Payload.pm

filter: Statementstmt 100% 107 / 107 Branchbran 50.0% 12 / 24 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 31 / 31 Podpod n/a totaltotal 92.5% 150 / 162 CC 13 SCAR 7.5
CC
13
Cov
91%
from_json
6.3
from_hashref
6.3
as_json
3.0
CRAP 2.1
« Discord.pm ↑ Summary
1 9 ▶use v5.14;
Subroutine __ANON__: called CC=1 SCAR=0.0
2 9 ▶use Moops;
Subroutine __ANON__: called CC=1 SCAR=0.0
3 5  
4 9 ▶class AnyEvent::Discord::Payload {
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 ▶ use JSON qw(decode_json encode_json);
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 our $VERSION = '0.1';
8 1 has version => ( is => 'ro', isa => Str, default => $VERSION );
9  
10 1 has op => ( is => 'rw', isa => Num );
11 1 has d => ( is => 'rw' );
12 1 has s => ( is => 'rw' );
13 1 has t => ( is => 'rw' );
14  
15 4 ▶ method from_json($class: Str $json) {
Subroutine BEGIN: called CC=1 SCAR=0.1
Subroutine BEGIN: called CC=1 SCAR=0.1
Subroutine from_json: called CC=6 SCAR=18.3
Branch: 5 branches
BranchTrueFalseTotal
@_ ? : 2 0 2
if @_ != 1 0 2 2
$#_ >= 0 ? : 2 0 2
if ($#_ >= 0) 2 0 2
Type::Tiny::XS::Str($json) or _failed_check(9, "Str", $json, "exception_class", "Error::TypeTiny::Assertion") 2 0 2
16 2 $class->new(decode_json($json));
17 }
18  
19 3 ▶ method from_hashref($class: HashRef $ref) {
Subroutine BEGIN: called CC=1 SCAR=0.1
Subroutine BEGIN: called CC=1 SCAR=0.1
Subroutine from_hashref: called CC=6 SCAR=18.3
Branch: 5 branches
BranchTrueFalseTotal
@_ ? : 5 0 5
if @_ != 1 0 5 5
$#_ >= 0 ? : 5 0 5
if ($#_ >= 0) 5 0 5
Ref::Util::XS::is_plain_hashref($ref) or _failed_check(22, "HashRef", $ref, "exception_class", "Error::TypeTiny::Assertion") 5 0 5
20 5 $class->new($ref);
21 }
22  
23 3 ▶ method as_json() {
Subroutine BEGIN: called CC=1 SCAR=0.1
Subroutine as_json: called CC=3 SCAR=11.1
Branch: 2 branches
BranchTrueFalseTotal
@_ ? : 1 0 1
if @_ != 0 0 1 1
24 1 return encode_json({
25 op => $self->op,
26 d => $self->d,
27 });
28 }
29 }
30  
31 5 1;
32  
33 =pod
34  
35 =head1 NAME
36  
37 AnyEvent::Discord::Payload - Represents a Discord payload
38  
39 =head1 DESCRIPTION
40  
41 https://discord.com/developers/docs/topics/gateway
42  
43 =head1 ACCESSORS
44  
45 =over 4
46  
47 =item op (Number)
48  
49 Opcode
50  
51 =item d (HashRef)
52  
53 Data structure for message
54  
55 =item t (String)
56  
57 Event name
58  
59 =back
60  
61 =head1 CAVEATS
62  
63 This is incredibly unfinished.
64  
65 =head1 AUTHOR
66  
67 Nick Melnick <nmelnick@cpan.org>
68  
69 =head1 COPYRIGHT AND LICENSE
70  
71 This software is copyright (c) 2021, Nick Melnick.
72  
73 This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
74  
75 =cut
« Discord.pm ↑ Summary