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   238 use 5.010001;
  16         53  
4 16     16   87 use strict;
  16         74  
  16         459  
5 16     16   84 use warnings;
  16         28  
  16         679  
6 16     16   73 use utf8;
  16         26  
  16         87  
7              
8 16     16   425 use SBOM::CycloneDX::BomRef;
  16         56  
  16         365  
9 16     16   6357 use SBOM::CycloneDX::PostalAddress;
  16         50  
  16         572  
10 16     16   108 use SBOM::CycloneDX::List;
  16         34  
  16         462  
11              
12 16     16   80 use Types::Standard qw(Str InstanceOf);
  16         29  
  16         102  
13 16     16   27946 use Types::TypeTiny qw(ArrayLike);
  16         30  
  16         92  
14              
15 16     16   7792 use Moo;
  16         30  
  16         80  
16 16     16   5165 use namespace::autoclean;
  16         33  
  16         95  
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 159     159 1 720 my $self = shift;
45              
46 159         183 my $json = {};
47              
48 159 50       1611 $json->{'bom-ref'} = $self->bom_ref if $self->bom_ref;
49 159 50       2128 $json->{name} = $self->name if $self->name;
50 159 50       637 $json->{address} = $self->address if %{$self->address->TO_JSON};
  159         1690  
51 159 50       212 $json->{url} = $self->url if @{$self->url};
  159         1611  
52 159 50       181 $json->{contact} = $self->contact if @{$self->contact};
  159         1688  
53              
54 159         330 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