File Coverage

blib/lib/SBOM/CycloneDX/PostalAddress.pm
Criterion Covered Total %
statement 33 33 100.0
branch 7 14 50.0
condition n/a
subroutine 9 9 100.0
pod 1 1 100.0
total 50 57 87.7


line stmt bran cond sub pod time code
1             package SBOM::CycloneDX::PostalAddress;
2              
3 16     16   453 use 5.010001;
  16         98  
4 16     16   103 use strict;
  16         56  
  16         551  
5 16     16   94 use warnings;
  16         52  
  16         840  
6 16     16   101 use utf8;
  16         32  
  16         131  
7              
8 16     16   624 use SBOM::CycloneDX::BomRef;
  16         61  
  16         716  
9              
10 16     16   90 use Types::Standard qw(Str InstanceOf);
  16         31  
  16         205  
11              
12 16     16   52938 use Moo;
  16         41  
  16         131  
13 16     16   7316 use namespace::autoclean;
  16         44  
  16         209  
14              
15             extends 'SBOM::CycloneDX::Base';
16              
17             has bom_ref => (
18             is => 'rw',
19             isa => InstanceOf ['SBOM::CycloneDX::BomRef'],
20             coerce => sub { ref($_[0]) ? $_[0] : SBOM::CycloneDX::BomRef->new($_[0]) }
21             );
22              
23             has country => (is => 'rw', isa => Str);
24             has region => (is => 'rw', isa => Str);
25             has locality => (is => 'rw', isa => Str);
26             has post_office_box_number => (is => 'rw', isa => Str);
27             has postal_code => (is => 'rw', isa => Str);
28             has street_address => (is => 'rw', isa => Str);
29              
30             sub TO_JSON {
31              
32 903     903 1 6344 my $self = shift;
33              
34 903         1580 my $json = {};
35              
36 903 50       16609 $json->{'bom-ref'} = $self->bom_ref if $self->bom_ref;
37 903 50       21025 $json->{country} = $self->country if $self->country;
38 903 50       20273 $json->{region} = $self->region if $self->region;
39 903 50       20249 $json->{locality} = $self->locality if $self->locality;
40 903 50       20148 $json->{postOfficeBoxNumber} = $self->post_office_box_number if $self->post_office_box_number;
41 903 50       20183 $json->{postalCode} = $self->postal_code if $self->postal_code;
42 903 50       19792 $json->{streetAddress} = $self->street_address if $self->street_address;
43              
44 903         7377 return $json;
45              
46             }
47              
48             1;
49              
50             =encoding utf-8
51              
52             =head1 NAME
53              
54             SBOM::CycloneDX::PostalAddress - Postal address
55              
56             =head1 SYNOPSIS
57              
58             SBOM::CycloneDX::PostalAddress->new();
59              
60              
61             =head1 DESCRIPTION
62              
63             L provide an address used to identify a contactable
64             location.
65              
66             =head2 METHODS
67              
68             L inherits all methods from L
69             and implements the following new ones.
70              
71             =over
72              
73             =item SBOM::CycloneDX::PostalAddress->new( %PARAMS )
74              
75             Properties:
76              
77             =over
78              
79             =item * C, An identifier which can be used to reference the
80             address elsewhere in the BOM. Every bom-ref must be unique within the BOM.
81             Value SHOULD not start with the BOM-Link intro 'urn:cdx:' to avoid
82             conflicts with BOM-Links.
83              
84             =item * C, The country name or the two-letter ISO 3166-1 country
85             code.
86              
87             =item * C, The locality or city within the country.
88              
89             =item * C, The post office box number.
90              
91             =item * C, The postal code.
92              
93             =item * C, The region or state in the country.
94              
95             =item * C, The street address.
96              
97             =back
98              
99             =item $postal_address->bom_ref
100              
101             =item $postal_address->country
102              
103             =item $postal_address->locality
104              
105             =item $postal_address->post_office_box_number
106              
107             =item $postal_address->postal_code
108              
109             =item $postal_address->region
110              
111             =item $postal_address->street_address
112              
113             =back
114              
115              
116             =head1 SUPPORT
117              
118             =head2 Bugs / Feature Requests
119              
120             Please report any bugs or feature requests through the issue tracker
121             at L.
122             You will be notified automatically of any progress on your issue.
123              
124             =head2 Source Code
125              
126             This is open source software. The code repository is available for
127             public review and contribution under the terms of the license.
128              
129             L
130              
131             git clone https://github.com/giterlizzi/perl-SBOM-CycloneDX.git
132              
133              
134             =head1 AUTHOR
135              
136             =over 4
137              
138             =item * Giuseppe Di Terlizzi
139              
140             =back
141              
142              
143             =head1 LICENSE AND COPYRIGHT
144              
145             This software is copyright (c) 2025-2026 by Giuseppe Di Terlizzi.
146              
147             This is free software; you can redistribute it and/or modify it under
148             the same terms as the Perl 5 programming language system itself.
149              
150             =cut