File Coverage

blib/lib/SBOM/CycloneDX/Component/SWID.pm
Criterion Covered Total %
statement 28 28 100.0
branch 5 10 50.0
condition n/a
subroutine 8 8 100.0
pod 1 1 100.0
total 42 47 89.3


line stmt bran cond sub pod time code
1             package SBOM::CycloneDX::Component::SWID;
2              
3 2     2   3605 use 5.010001;
  2         11  
4 2     2   14 use strict;
  2         5  
  2         58  
5 2     2   10 use warnings;
  2         4  
  2         144  
6 2     2   13 use utf8;
  2         6  
  2         17  
7              
8 2     2   96 use Types::Standard qw(Str);
  2         18  
  2         22  
9              
10 2     2   6925 use Moo;
  2         5  
  2         17  
11 2     2   1029 use namespace::autoclean;
  2         6  
  2         24  
12              
13             extends 'SBOM::CycloneDX::Base';
14              
15             has tag_id => (is => 'rw', isa => Str, required => 1);
16             has name => (is => 'rw', isa => Str, required => 1);
17             has version => (is => 'rw', isa => Str);
18             has tag_version => (is => 'rw', isa => Str);
19             has patch => (is => 'rw', isa => Str);
20             has text => (is => 'rw', isa => Str);
21             has url => (is => 'rw', isa => Str);
22              
23             sub TO_JSON {
24              
25 210     210 1 643 my $self = shift;
26              
27 210         5156 my $json = {tagId => $self->tag_id, name => $self->name};
28              
29 210 50       11621 $json->{version} = $self->version if $self->version;
30 210 50       10085 $json->{tagVersion} = $self->tag_version if $self->tag_version;
31 210 50       5535 $json->{patch} = $self->patch if $self->patch;
32 210 50       6005 $json->{text} = $self->text if $self->text;
33 210 50       5209 $json->{url} = $self->url if $self->url;
34              
35 210         6212 return $json;
36              
37             }
38              
39             1;
40              
41             =encoding utf-8
42              
43             =head1 NAME
44              
45             SBOM::CycloneDX::Component::SWID - SWID Tag
46              
47             =head1 SYNOPSIS
48              
49             SBOM::CycloneDX::Component::SWID->new();
50              
51              
52             =head1 DESCRIPTION
53              
54             L specifies metadata and content for
55             ISO-IEC 19770-2 Software Identification (SWID) Tags.
56              
57             =head2 METHODS
58              
59             L inherits all methods from L
60             and implements the following new ones.
61              
62             =over
63              
64             =item SBOM::CycloneDX::Component::SWID->new( %PARAMS )
65              
66             Properties:
67              
68             =over
69              
70             =item * C, Maps to the name of a SoftwareIdentity.
71              
72             =item * C, Maps to the patch of a SoftwareIdentity.
73              
74             =item * C, Maps to the tagId of a SoftwareIdentity.
75              
76             =item * C, Maps to the tagVersion of a SoftwareIdentity.
77              
78             =item * C, Specifies the metadata and content of the SWID tag.
79              
80             =item * C, The URL to the SWID file.
81              
82             =item * C, Maps to the version of a SoftwareIdentity.
83              
84             =back
85              
86             =item $swid->name
87              
88             =item $swid->patch
89              
90             =item $swid->tag_id
91              
92             =item $swid->tag_version
93              
94             =item $swid->text
95              
96             =item $swid->url
97              
98             =item $swid->version
99              
100             =back
101              
102              
103              
104             =head1 SUPPORT
105              
106             =head2 Bugs / Feature Requests
107              
108             Please report any bugs or feature requests through the issue tracker
109             at L.
110             You will be notified automatically of any progress on your issue.
111              
112             =head2 Source Code
113              
114             This is open source software. The code repository is available for
115             public review and contribution under the terms of the license.
116              
117             L
118              
119             git clone https://github.com/giterlizzi/perl-SBOM-CycloneDX.git
120              
121              
122             =head1 AUTHOR
123              
124             =over 4
125              
126             =item * Giuseppe Di Terlizzi
127              
128             =back
129              
130              
131             =head1 LICENSE AND COPYRIGHT
132              
133             This software is copyright (c) 2025-2026 by Giuseppe Di Terlizzi.
134              
135             This is free software; you can redistribute it and/or modify it under
136             the same terms as the Perl 5 programming language system itself.
137              
138             =cut