lib/IO/K8s/ApiextensionsApiserver/Pkg/Apis/Apiextensions/V1/JSONSchemaPropsOrArray.pm

filter: Statementstmt 97.3% 36 / 37 Branchbran 90.0% 9 / 10 Conditioncond 66.6% 2 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 88.8% 8 / 9 Podpod 100% 3 / 3 totaltotal 90.6% 58 / 64 CC 7 SCAR 7.6
CC
7
Cov
94%
TO_JSON
3.0
FROM_STRUCT
3.0
_build__json_encoder
2.0
CRAP 2.1
« lib/IO/K8s/Types/Net.pm ↑ Summary lib/IO/K8s/Manifest.pm »
1 package IO::K8s::ApiextensionsApiserver::Pkg::Apis::Apiextensions::V1::JSONSchemaPropsOrArray;
2 # ABSTRACT: JSONSchemaPropsOrArray represents a value that can either be a JSONSchemaProps or an array of JSONSchemaProps. Mainly here for serialization purposes.
3 19 our $VERSION = '1.112';
4 19 ▶use v5.10;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 19 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 19 ▶use Types::Standard ();
Subroutine BEGIN: called CC=1 SCAR=0.0
7 19 ▶use JSON::MaybeXS ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 # Carp treats IO::K8s as part of this class (k175), as IO::K8s::List does
10 # (k170): a schema arm is inflated through IO::K8s, and a shape croak raised
11 # there -- a plain scalar where a schema belongs -- names the line that called
12 # FROM_STRUCT, or IO::K8s itself on the way in, not the inflation call below.
13 # A caller in any other package still sees its own line.
14 19 our @CARP_NOT = ('IO::K8s');
15  
16 19 my $PROPS = 'IO::K8s::ApiextensionsApiserver::Pkg::Apis::Apiextensions::V1::JSONSchemaProps';
17  
18  
19 19 has schema => (
20 is => 'rw',
21 isa => Types::Standard::Maybe[ Types::Standard::InstanceOf[$PROPS] ],
22 );
23  
24  
25 19 has schemas => (
26 is => 'rw',
27 isa => Types::Standard::Maybe[
28 Types::Standard::ArrayRef[ Types::Standard::InstanceOf[$PROPS] ]
29 ],
30 );
31  
32  
33 0 ▶sub _build__json_encoder {
Subroutine _build__json_encoder: not called CC=1 SCAR=6.9
34 0 return JSON::MaybeXS->new(utf8 => 1, canonical => 1, allow_nonref => 1);
35 }
36  
37  
38 8 ▶sub is_schema {
Subroutine is_schema: called CC=2 SCAR=6.9
Pod documented
39 8 my ($self) = @_;
40 8 ▶ return defined $self->schemas ? 0 : 1;
Branch: 1 branch
BranchTrueFalseTotal
defined $self->schemas ? : 4 4 8
41 }
42  
43  
44 5326 ▶sub FROM_STRUCT {
Subroutine FROM_STRUCT: called CC=3 SCAR=11.0
Pod documented
45 5326 my ($class, $struct, $k8s) = @_;
46 5326 ▶ $k8s //= do { require IO::K8s; IO::K8s->new };
Condition66%2/3
$k8s //= do { require IO::K8s; "IO::K8s"->new }
l!l&&r!l&&!r
532330
MC/DC0%0/2
$k8s //= do { require IO::K8s; "IO::K8s"->new }
$k8s do { require IO::K8s; "IO::K8s"->new }
Truth table66%2/3
A //= B
A= $k8sB= do { require IO::K8s; "IO::K8s"->new }
ABresult
1X1
011
000
47  
48 return $class->new(
49 5326 ▶ schemas => [ map { $k8s->_struct_to_object_expanded($PROPS, $_) } @$struct ],
Branch: 1 branch
BranchTrueFalseTotal
if ref $struct eq "ARRAY" 80 5246 5326
50 ) if ref $struct eq 'ARRAY';
51  
52 5246 return $class->new(schema => $k8s->_struct_to_object_expanded($PROPS, $struct));
53 }
54  
55  
56 758 ▶sub TO_JSON {
Subroutine TO_JSON: called CC=3 SCAR=11.0
Pod documented
57 758 my ($self) = @_;
58 758 my $schemas = $self->schemas;
59 758 ▶ return [ map { $_->TO_JSON } @$schemas ] if defined $schemas;
Branch: 1 branch
BranchTrueFalseTotal
if defined $schemas 117 641 758
60 641 my $schema = $self->schema;
61 641 ▶ return defined $schema ? $schema->TO_JSON : undef;
Branch: 1 branch
BranchTrueFalseTotal
defined $schema ? : 641 0 641
62 }
63  
64 # The node a spec path walks into (IO::K8s::Role::SpecBuilder, k172): the
65 # arm in use -- the schemas array, named so an element written into it is
66 # checked against that attribute, or the single schema.
67 8 ▶sub _spec_path_node {
Subroutine _spec_path_node: called CC=2 SCAR=6.9
68 8 my ($self) = @_;
69 8 my $schemas = $self->schemas;
70 8 ▶ return defined $schemas ? ($schemas, 'schemas') : ($self->schema);
Branch: 1 branch
BranchTrueFalseTotal
defined $schemas ? : 3 5 8
71 }
72  
73 19 with 'IO::K8s::Role::Resource';
74  
75 19 1;
76  
77 __END__
« lib/IO/K8s/Types/Net.pm ↑ Summary lib/IO/K8s/Manifest.pm »