File Coverage

blib/lib/SBOM/CycloneDX/License/Licensing.pm
Criterion Covered Total %
statement 54 54 100.0
branch 8 16 50.0
condition n/a
subroutine 14 14 100.0
pod 1 1 100.0
total 77 85 90.5


line stmt bran cond sub pod time code
1             package SBOM::CycloneDX::License::Licensing;
2              
3 16     16   354 use 5.010001;
  16         71  
4 16     16   94 use strict;
  16         36  
  16         641  
5 16     16   88 use warnings;
  16         38  
  16         836  
6 16     16   128 use utf8;
  16         38  
  16         96  
7              
8 16     16   639 use SBOM::CycloneDX::Enum;
  16         33  
  16         785  
9 16     16   8505 use SBOM::CycloneDX::License::Licensee;
  16         79  
  16         671  
10 16     16   9545 use SBOM::CycloneDX::License::Licensor;
  16         72  
  16         721  
11 16     16   8113 use SBOM::CycloneDX::License::Purchaser;
  16         69  
  16         702  
12 16     16   124 use SBOM::CycloneDX::List;
  16         38  
  16         576  
13              
14 16     16   949 use Types::Standard qw(Str Enum InstanceOf);
  16         1292  
  16         1133  
15 16     16   30716 use Types::TypeTiny qw(ArrayLike);
  16         251  
  16         160  
16              
17 16     16   9448 use Moo;
  16         42  
  16         86  
18 16     16   6239 use namespace::autoclean;
  16         40  
  16         165  
19              
20             extends 'SBOM::CycloneDX::Base';
21              
22             has alt_ids => (is => 'rw', isa => ArrayLike [Str], default => sub { SBOM::CycloneDX::List->new });
23              
24             has licensor => (
25             is => 'rw',
26             isa => InstanceOf ['SBOM::CycloneDX::License::Licensor'],
27             default => sub { SBOM::CycloneDX::License::Licensor->new }
28             );
29              
30             has licensee => (
31             is => 'rw',
32             isa => InstanceOf ['SBOM::CycloneDX::License::Licensee'],
33             default => sub { SBOM::CycloneDX::License::Licensee->new }
34             );
35              
36             has purchaser => (
37             is => 'rw',
38             isa => InstanceOf ['SBOM::CycloneDX::License::Purchaser'],
39             default => sub { SBOM::CycloneDX::License::Purchaser->new }
40             );
41              
42             has purchase_order => (is => 'rw', isa => Str);
43              
44             has license_types => (
45             is => 'rw',
46             isa => ArrayLike [Enum [SBOM::CycloneDX::Enum->values('LICENSE_TYPE')]],
47             default => sub { SBOM::CycloneDX::List->new }
48             );
49              
50             has last_renewal => (
51             is => 'rw',
52             isa => InstanceOf ['SBOM::CycloneDX::Timestamp'],
53             coerce => sub { ref($_[0]) ? $_[0] : SBOM::CycloneDX::Timestamp->new($_[0]) }
54             );
55              
56             has expiration => (
57             is => 'rw',
58             isa => InstanceOf ['SBOM::CycloneDX::Timestamp'],
59             coerce => sub { ref($_[0]) ? $_[0] : SBOM::CycloneDX::Timestamp->new($_[0]) }
60             );
61              
62             sub TO_JSON {
63              
64 301     301 1 2532 my $self = shift;
65              
66 301         548 my $json = {};
67              
68 301 50       552 $json->{altIds} = $self->alt_ids if @{$self->alt_ids};
  301         5973  
69 301 50       540 $json->{licensor} = $self->licensor if %{$self->licensor->TO_JSON};
  301         5906  
70 301 50       570 $json->{licensee} = $self->licensee if %{$self->licensee->TO_JSON};
  301         6210  
71 301 50       573 $json->{purchaser} = $self->purchaser if %{$self->purchaser->TO_JSON};
  301         5923  
72 301 50       6072 $json->{purchaseOrder} = $self->purchase_order if $self->purchase_order;
73 301 50       2137 $json->{licenseTypes} = $self->license_types if @{$self->license_types};
  301         5839  
74 301 50       5922 $json->{lastRenewal} = $self->last_renewal if $self->last_renewal;
75 301 50       6977 $json->{expiration} = $self->expiration if $self->expiration;
76              
77 301         2607 return $json;
78              
79             }
80              
81             1;
82              
83             =encoding utf-8
84              
85             =head1 NAME
86              
87             SBOM::CycloneDX::License::Licensing - Licensing information
88              
89             =head1 SYNOPSIS
90              
91             SBOM::CycloneDX::License::Licensing->new();
92              
93              
94             =head1 DESCRIPTION
95              
96             L provides the licensing details describing the
97             licensor/licensee, license type, renewal and expiration dates, and other
98             important metadata
99              
100             =head2 METHODS
101              
102             L inherits all methods from L
103             and implements the following new ones.
104              
105             =over
106              
107             =item SBOM::CycloneDX::License::Licensing->new( %PARAMS )
108              
109             Properties:
110              
111             =over
112              
113             =item * C, License identifiers that may be used to manage licenses
114             and their lifecycle
115              
116             =item * C, The timestamp indicating when the current license
117             expires (if applicable).
118              
119             =item * C, The timestamp indicating when the license was last
120             renewed. For new purchases, this is often the purchase or acquisition date.
121             For non-perpetual licenses or subscriptions, this is the timestamp of when
122             the license was last renewed.
123              
124             =item * C, The type of license(s) that was granted to the
125             licensee.
126              
127             =item * C, The individual or organization for which a license was
128             granted to
129              
130             =item * C, The individual or organization that grants a license to
131             another individual or organization
132              
133             =item * C, The purchase order identifier the purchaser sent
134             to a supplier or vendor to authorize a purchase
135              
136             =item * C, The individual or organization that purchased the
137             license
138              
139             =back
140              
141             =item $licensing->alt_ids
142              
143             =item $licensing->expiration
144              
145             =item $licensing->last_renewal
146              
147             =item $licensing->license_types
148              
149             =item $licensing->licensee
150              
151             =item $licensing->licensor
152              
153             =item $licensing->purchase_order
154              
155             =item $licensing->purchaser
156              
157             =back
158              
159              
160             =head1 SUPPORT
161              
162             =head2 Bugs / Feature Requests
163              
164             Please report any bugs or feature requests through the issue tracker
165             at L.
166             You will be notified automatically of any progress on your issue.
167              
168             =head2 Source Code
169              
170             This is open source software. The code repository is available for
171             public review and contribution under the terms of the license.
172              
173             L
174              
175             git clone https://github.com/giterlizzi/perl-SBOM-CycloneDX.git
176              
177              
178             =head1 AUTHOR
179              
180             =over 4
181              
182             =item * Giuseppe Di Terlizzi
183              
184             =back
185              
186              
187             =head1 LICENSE AND COPYRIGHT
188              
189             This software is copyright (c) 2025-2026 by Giuseppe Di Terlizzi.
190              
191             This is free software; you can redistribute it and/or modify it under
192             the same terms as the Perl 5 programming language system itself.
193              
194             =cut