blib/lib/Web/ID.pm

filter: Statementstmt 76.3% 42 / 55 Branchbran 33.3% 4 / 12 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 78.5% 11 / 14 Podpod 100% 2 / 2 totaltotal 63.4% 59 / 93 CC 11 SCAR 24.9
CC
11
Cov
63%
get
42.0
_build_first_valid_san
4.0
_build_valid
3.0
CRAP 12.1
« blib/lib/Web/ID/Util.pm ↑ Summary blib/lib/Plack/Middleware/Auth/WebID.pm »
1 package Web::ID;
2  
3 2 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 $Web::ID::AUTHORITY = 'cpan:TOBYINK';
8 2 $Web::ID::VERSION = '1.927';
9 }
10  
11 2 ▶use Web::ID::Types -types;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 2 ▶use Web::ID::Certificate;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 2 ▶use Web::ID::Util qw(:default uniq);
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 2 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 2 ▶use namespace::sweep;
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 2 has certificate => (
19 is => read_only,
20 isa => Certificate,
21 required => true,
22 coerce => true,
23 );
24  
25 2 has uri => (
26 is => read_only,
27 isa => Uri,
28 lazy_build => true,
29 coerce => true,
30 );
31  
32 2 has profile => (
33 is => read_only,
34 isa => Model,
35 lazy_build => true,
36 );
37  
38 2 has valid => (
39 is => read_only,
40 isa => Bool,
41 lazy_build => true,
42 );
43  
44 2 has first_valid_san => (
45 is => read_only,
46 isa => San | Undef,
47 lazy_build => true,
48 );
49  
50 sub _build_valid
51 7 ▶{
Subroutine _build_valid: called CC=3 SCAR=11.0
52 7 my ($self) = @_;
53 7 ▶ return false unless $self->certificate->timely;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->certificate->timely 0 7 7
54 7 ▶ return true if defined $self->first_valid_san;
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->first_valid_san 5 2 7
55 2 return false;
56 }
57  
58 sub _build_uri
59 5 ▶{
Subroutine _build_uri: called CC=1 SCAR=0.0
60 5 my ($self) = @_;
61 5 $self->first_valid_san->uri_object;
62 }
63  
64 sub _build_profile
65 0 ▶{
Subroutine _build_profile: not called CC=1 SCAR=6.9
66 0 my ($self) = @_;
67 0 $self->first_valid_san->model;
68 }
69  
70 sub _build_first_valid_san
71 7 ▶{
Subroutine _build_first_valid_san: called CC=4 SCAR=13.9
72 7 my ($self) = @_;
73 7 my $cert = $self->certificate;
74 7 my @sans = @{ $cert->subject_alt_names };
75
76 7 foreach my $san (@sans)
77 {
78 7 foreach my $key ( $san->associated_keys )
79 {
80 5 ▶ return $san if $key->rsa_equal($cert);
Branch: 1 branch
BranchTrueFalseTotal
if $key->rsa_equal($cert) 5 0 5
81 }
82 }
83
84 2 return undef;
85 }
86  
87 sub node
88 0 ▶{
Subroutine node: not called CC=1 SCAR=6.9
Pod documented
89 0 my ($self) = @_;
90 0 "RDF::Trine::Node::Resource"->new($self->uri.'');
91 }
92  
93 sub get
94 0 ▶{
Subroutine get: not called CC=6 SCAR=37.4
Pod documented
95 0 my $self = shift;
96 my @pred = map {
97 0 ▶ if (blessed $_ and $_->isa("RDF::Trine::Node")) { $_ }
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($_) and $_->isa('RDF::Trine::Node')) { } 0 0 0
Condition0%0/3
builtin::blessed($_) and $_->isa("RDF::Trine::Node")
!ll&&!rl&&r
000
MC/DC0%0/2
builtin::blessed($_) and $_->isa("RDF::Trine::Node")
builtin::blessed($_) $_->isa("RDF::Trine::Node")
Truth table0%0/3
A and B
A= builtin::blessed($_)B= $_->isa("RDF::Trine::Node")
ABresult
0X0
100
111
98 0 else { u $_ }
99 } @_;
100
101 my @results = uniq
102 0 ▶ map { $_->is_resource ? $_->uri : $_->literal_value }
Branch: 1 branch
BranchTrueFalseTotal
$_->is_resource ? : 0 0 0
103 0 ▶ grep { $_->is_literal or $_->is_resource }
Condition0%0/3
$_->is_literal || $_->is_resource
l!l&&r!l&&!r
000
MC/DC0%0/2
$_->is_literal || $_->is_resource
$_->is_literal $_->is_resource
Truth table0%0/3
A || B
A= $_->is_literalB= $_->is_resource
ABresult
1X1
011
000
104 $self->profile->objects_for_predicate_list($self->node, @pred);
105
106 0 ▶ wantarray ? @results : $results[0];
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
107 }
108  
109 2 __PACKAGE__
110 __END__
« blib/lib/Web/ID/Util.pm ↑ Summary blib/lib/Plack/Middleware/Auth/WebID.pm »