SDK.pm

filter: Statementstmt 65.5% 19 / 29 Branchbran 50.0% 2 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 46.6% 7 / 15 Podpod 0.0% 0 / 11 totaltotal 47.4% 28 / 59 CC 5 SCAR 12.3
CC
5
Cov
64%
get_provider_metadata
12.0
set_provider
3.0
clear_providers
2.0
CRAP 3.4
« Client.pm ↑ Summary ProviderRegistry.pm »
1 1 ▶use v5.36;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 package OpenFeature::SDK v0.1.1;
3  
4 1 ▶use OpenFeature::ProviderRegistry;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use OpenFeature::Client;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use OpenFeature::EvaluationContext;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 =encoding UTF-8
9  
10 =head1 NAME
11  
12 OpenFeature::SDK - OpenFeature SDK for Perl
13  
14 =head1 SYNOPSIS
15  
16 use v5.36;
17 use OpenFeature::SDK;
18 my $openfeature_sdk = OpenFeature::SDK->new();
19 $openfeature_sdk->set_provider($someProvider, 'someDomain');
20 my $openfeature_client = $openfeature_sdk->get_client('someDomain');
21 my $boolean_flag = $openfeature_client->get_boolean_value('flagName', 0);
22  
23 =head1 DESCRIPTION
24  
25 The future of feature flagging is here! Which is an assortment of functions to
26 call L<providers|https://openfeature.dev/specification/sections/providers> to
27 get your flag details out.
28  
29 OpenFeature provides 5 distinct types of flags in: "Boolean", "String",
30 "Integer", "Float" and "Object". The job of this SDK package is to provider the
31 global configuration layer and access to the underlying L<Openfeature::Client>
32 package.
33  
34 =cut
35  
36 1 ▶sub new($class) {
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
37 1 my $self = {};
38 1 $self->{'provider_registry'} = OpenFeature::ProviderRegistry->new();
39 1 $self->{'evaluation_context'} = OpenFeature::EvaluationContext->new({});
40 1 bless $self, $class
41 }
42  
43 3 ▶sub set_provider($self, $provider, $domain = undef) {
Subroutine set_provider: called CC=3 SCAR=11.0
Pod undocumented
44 defined $domain
45 ? $self->{'provider_registry'}->set_provider($domain, $provider)
46 3 ▶ : $self->{'provider_registry'}->set_default_provider($provider)
Branch: 1 branch
BranchTrueFalseTotal
defined $domain ? : 2 1 3
47 }
48  
49 0 ▶sub clear_providers($self) {
Subroutine clear_providers: not called CC=1 SCAR=6.9
Pod undocumented
50 0 $self->{'provider_registry'}->clear_providers()
51 }
52  
53 1 ▶sub get_client($self, $domain) {
Subroutine get_client: called CC=1 SCAR=0.0
Pod undocumented
54 OpenFeature::Client->new(
55 1 $self->{'provider_registry'},
56 $domain,
57 )
58 }
59  
60 0 ▶sub get_evaluation_context($self) {
Subroutine get_evaluation_context: not called CC=1 SCAR=6.9
Pod undocumented
61 0 $self->{'evaluation_context'}
62 }
63  
64 0 ▶sub set_evaluation_context($self, $new_context) {
Subroutine set_evaluation_context: not called CC=1 SCAR=6.9
Pod undocumented
65 0 $self->{'evaluation_context'} = $new_context
66 }
67  
68 0 ▶sub get_provider_metadata($self, $domain = undef) {
Subroutine get_provider_metadata: not called CC=3 SCAR=24.8
Pod undocumented
69 defined $domain
70 ? $self->{'provider_registry'}->get_provider($domain)->get_metadata()
71 0 ▶ : $self->{'provider_registry'}->get_default_provider()->get_metadata()
Branch: 1 branch
BranchTrueFalseTotal
defined $domain ? : 0 0 0
72 }
73  
74 0 ▶sub add_hooks($self, $new_hooks) {
Subroutine add_hooks: not called CC=1 SCAR=6.9
Pod undocumented
75 0 my $original_hooks = $self->{'hooks'};
76 0 $self->{'hooks'} = [@$original_hooks, @$new_hooks]
77 }
78  
79 0 ▶sub clear_hooks($self) {
Subroutine clear_hooks: not called CC=1 SCAR=6.9
Pod undocumented
80 0 $self->{'hooks'} = []
81 }
82  
83 0 ▶sub get_hooks($self) {
Subroutine get_hooks: not called CC=1 SCAR=6.9
Pod undocumented
84 0 $self->{'hooks'}
85 }
86  
87 0 ▶sub shutdown($self) {
Subroutine shutdown: not called CC=1 SCAR=6.9
Pod undocumented
88 0 $self->{'provider_registry'}->shutdown_all_providers()
89 }
90  
91 1 1;
92  
93 =head1 Things left to implement
94  
95 =head2 Event handling stuff
96  
97 =over
98  
99 =item * add_handler
100  
101 =item * remove_handler
102  
103 =back
104  
105 =head1 AUTHOR
106  
107 Philipp Böschen <catouc@philipp.boeschen.me>
108  
109 =head1 CONTRIBUTORS
110  
111 None so far.
112  
113 =head1 COPYRIGHT
114  
115 Copyright (c) 2024 the OpenFeature::SDK L</AUTHOR> and L</CONTRIBUTORS>
116 as listed above.
117  
118 =head1 LICENSE
119  
120 This library is free software and may be distributed under the same terms
121 as perl itself. See L<https://dev.perl.org/licenses/>.
122  
123 =cut
« Client.pm ↑ Summary ProviderRegistry.pm »