File Coverage

blib/lib/SBOM/CycloneDX/Annotation/Annotator.pm
Criterion Covered Total %
statement 23 34 67.6
branch 0 10 0.0
condition n/a
subroutine 8 9 88.8
pod 1 1 100.0
total 32 54 59.2


line stmt bran cond sub pod time code
1             package SBOM::CycloneDX::Annotation::Annotator;
2              
3 1     1   1796 use 5.010001;
  1         5  
4 1     1   8 use strict;
  1         2  
  1         31  
5 1     1   5 use warnings;
  1         2  
  1         68  
6 1     1   6 use utf8;
  1         3  
  1         9  
7              
8 1     1   52 use Carp;
  1         2  
  1         120  
9 1     1   7 use Types::Standard qw(InstanceOf);
  1         2  
  1         12  
10              
11 1     1   3424 use Moo;
  1         2  
  1         8  
12 1     1   316 use namespace::autoclean;
  1         2  
  1         11  
13              
14             extends 'SBOM::CycloneDX::Base';
15              
16             has organization => (is => 'rw', isa => InstanceOf ['SBOM::CycloneDX::OrganizationalEntity']);
17             has individual => (is => 'rw', isa => InstanceOf ['SBOM::CycloneDX::OrganizationalContact']);
18             has component => (is => 'rw', isa => InstanceOf ['SBOM::CycloneDX::Component']);
19             has service => (is => 'rw', isa => InstanceOf ['SBOM::CycloneDX::Service']);
20              
21             sub TO_JSON {
22              
23 0     0 1   my $self = shift;
24              
25 0           my $json = {};
26              
27 0 0         $json->{organization} = $self->organization if $self->organization;
28 0 0         $json->{individual} = $self->individual if $self->individual;
29 0 0         $json->{component} = $self->component if $self->component;
30 0 0         $json->{service} = $self->service if $self->service;
31              
32 0           my @check = keys %{$json};
  0            
33              
34 0 0         if (scalar @check != 1) {
35 0           Carp::croak '"organization", "individual", "component" and "service" cannot be used at the same time';
36             }
37              
38 0           return $json;
39              
40             }
41              
42             1;
43              
44             =encoding utf-8
45              
46             =head1 NAME
47              
48             SBOM::CycloneDX::Annotation::Annotator - Annotator
49              
50             =head1 SYNOPSIS
51              
52             SBOM::CycloneDX::Annotation::Annotator->new();
53              
54              
55             =head1 DESCRIPTION
56              
57             L provides the organization, person,
58             component, or service which created the textual content of the annotation.
59              
60             =head2 METHODS
61              
62             L inherits all methods from L
63             and implements the following new ones.
64              
65             =over
66              
67             =item SBOM::CycloneDX::Annotation::Annotator->new( %PARAMS )
68              
69             Properties:
70              
71             =over
72              
73             =item * C, The tool or component that created the annotation
74              
75             =item * C, The person that created the annotation
76              
77             =item * C, The organization that created the annotation
78              
79             =item * C, The service that created the annotation
80              
81             =back
82              
83             =item $annotator->component
84              
85             =item $annotator->individual
86              
87             =item $annotator->organization
88              
89             =item $annotator->service
90              
91             =back
92              
93              
94             =head1 SUPPORT
95              
96             =head2 Bugs / Feature Requests
97              
98             Please report any bugs or feature requests through the issue tracker
99             at L.
100             You will be notified automatically of any progress on your issue.
101              
102             =head2 Source Code
103              
104             This is open source software. The code repository is available for
105             public review and contribution under the terms of the license.
106              
107             L
108              
109             git clone https://github.com/giterlizzi/perl-SBOM-CycloneDX.git
110              
111              
112             =head1 AUTHOR
113              
114             =over 4
115              
116             =item * Giuseppe Di Terlizzi
117              
118             =back
119              
120              
121             =head1 LICENSE AND COPYRIGHT
122              
123             This software is copyright (c) 2025-2026 by Giuseppe Di Terlizzi.
124              
125             This is free software; you can redistribute it and/or modify it under
126             the same terms as the Perl 5 programming language system itself.
127              
128             =cut