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   308 use 5.010001;
  16         65  
4 16     16   99 use strict;
  16         34  
  16         500  
5 16     16   83 use warnings;
  16         41  
  16         919  
6 16     16   114 use utf8;
  16         46  
  16         206  
7              
8 16     16   688 use SBOM::CycloneDX::BomRef;
  16         41  
  16         813  
9              
10 16     16   142 use Types::Standard qw(Str InstanceOf);
  16         79  
  16         184  
11              
12 16     16   52542 use Moo;
  16         44  
  16         126  
13 16     16   6879 use namespace::autoclean;
  16         38  
  16         187  
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 5829 my $self = shift;
33              
34 903         1256 my $json = {};
35              
36 903 50       14400 $json->{'bom-ref'} = $self->bom_ref if $self->bom_ref;
37 903 50       18153 $json->{country} = $self->country if $self->country;
38 903 50       20598 $json->{region} = $self->region if $self->region;
39 903 50       17643 $json->{locality} = $self->locality if $self->locality;
40 903 50       19237 $json->{postOfficeBoxNumber} = $self->post_office_box_number if $self->post_office_box_number;
41 903 50       17677 $json->{postalCode} = $self->postal_code if $self->postal_code;
42 903 50       18084 $json->{streetAddress} = $self->street_address if $self->street_address;
43              
44 903         6320 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