File Coverage

blib/lib/SBOM/CycloneDX/OrganizationalEntity.pm
Criterion Covered Total %
statement 43 43 100.0
branch 5 10 50.0
condition n/a
subroutine 12 12 100.0
pod 1 1 100.0
total 61 66 92.4


line stmt bran cond sub pod time code
1             package SBOM::CycloneDX::OrganizationalEntity;
2              
3 16     16   283 use 5.010001;
  16         65  
4 16     16   127 use strict;
  16         83  
  16         531  
5 16     16   82 use warnings;
  16         53  
  16         834  
6 16     16   143 use utf8;
  16         57  
  16         155  
7              
8 16     16   643 use SBOM::CycloneDX::BomRef;
  16         36  
  16         598  
9 16     16   8900 use SBOM::CycloneDX::PostalAddress;
  16         76  
  16         741  
10 16     16   143 use SBOM::CycloneDX::List;
  16         37  
  16         560  
11              
12 16     16   108 use Types::Standard qw(Str InstanceOf);
  16         40  
  16         122  
13 16     16   30276 use Types::TypeTiny qw(ArrayLike);
  16         45  
  16         128  
14              
15 16     16   9420 use Moo;
  16         43  
  16         103  
16 16     16   7250 use namespace::autoclean;
  16         44  
  16         130  
17              
18             extends 'SBOM::CycloneDX::Base';
19              
20             has bom_ref => (
21             is => 'rw',
22             isa => InstanceOf ['SBOM::CycloneDX::BomRef'],
23             coerce => sub { ref($_[0]) ? $_[0] : SBOM::CycloneDX::BomRef->new($_[0]) }
24             );
25              
26             has name => (is => 'rw', isa => Str);
27              
28             has address => (
29             is => 'rw',
30             isa => InstanceOf ['SBOM::CycloneDX::PostalAddress'],
31             default => sub { SBOM::CycloneDX::PostalAddress->new }
32             );
33              
34             has url => (is => 'rw', isa => ArrayLike [Str], default => sub { SBOM::CycloneDX::List->new });
35              
36             has contact => (
37             is => 'rw',
38             isa => ArrayLike [InstanceOf ['SBOM::CycloneDX::OrganizationalContact']],
39             default => sub { SBOM::CycloneDX::List->new }
40             );
41              
42             sub TO_JSON {
43              
44 903     903 1 6472 my $self = shift;
45              
46 903         1463 my $json = {};
47              
48 903 50       16440 $json->{'bom-ref'} = $self->bom_ref if $self->bom_ref;
49 903 50       20469 $json->{name} = $self->name if $self->name;
50 903 50       7013 $json->{address} = $self->address if %{$self->address->TO_JSON};
  903         16600  
51 903 50       1981 $json->{url} = $self->url if @{$self->url};
  903         18669  
52 903 50       1677 $json->{contact} = $self->contact if @{$self->contact};
  903         17440  
53              
54 903         3078 return $json;
55              
56             }
57              
58             1;
59              
60             =encoding utf-8
61              
62             =head1 NAME
63              
64             SBOM::CycloneDX::OrganizationalEntity - Organizational Entity
65              
66             =head1 SYNOPSIS
67              
68             SBOM::CycloneDX::OrganizationalEntity->new();
69              
70              
71             =head1 DESCRIPTION
72              
73             L provides the organization entity object.
74              
75             =head2 METHODS
76              
77             L inherits all methods from L
78             and implements the following new ones.
79              
80             =over
81              
82             =item SBOM::CycloneDX::OrganizationalEntity->new( %PARAMS )
83              
84             Properties:
85              
86             =over
87              
88             =item * C
, The physical address (location) of the organization
89              
90             =item * C, An identifier which can be used to reference the object
91             elsewhere in the BOM. Every bom-ref must be unique within the BOM.
92             Value SHOULD not start with the BOM-Link intro 'urn:cdx:' to avoid
93             conflicts with BOM-Links.
94              
95             =item * C, A contact at the organization. Multiple contacts are
96             allowed.
97              
98             =item * C, The name of the organization
99              
100             =item * C, The URL of the organization. Multiple URLs are allowed.
101              
102             =back
103              
104             =item $organizational_entity->address
105              
106             =item $organizational_entity->bom_ref
107              
108             =item $organizational_entity->contact
109              
110             =item $organizational_entity->name
111              
112             =item $organizational_entity->url
113              
114             =back
115              
116              
117             =head1 SUPPORT
118              
119             =head2 Bugs / Feature Requests
120              
121             Please report any bugs or feature requests through the issue tracker
122             at L.
123             You will be notified automatically of any progress on your issue.
124              
125             =head2 Source Code
126              
127             This is open source software. The code repository is available for
128             public review and contribution under the terms of the license.
129              
130             L
131              
132             git clone https://github.com/giterlizzi/perl-SBOM-CycloneDX.git
133              
134              
135             =head1 AUTHOR
136              
137             =over 4
138              
139             =item * Giuseppe Di Terlizzi
140              
141             =back
142              
143              
144             =head1 LICENSE AND COPYRIGHT
145              
146             This software is copyright (c) 2025-2026 by Giuseppe Di Terlizzi.
147              
148             This is free software; you can redistribute it and/or modify it under
149             the same terms as the Perl 5 programming language system itself.
150              
151             =cut