FOSSology
4.4.0
Open Source License Compliance by Open Source Software
Coordinate.php
1
<?php
2
/*
3
SPDX-FileCopyrightText: © 2020 Siemens AG
4
5
SPDX-License-Identifier: GPL-2.0-only
6
*/
11
namespace
Fossology\Lib\Data\Spasht
;
12
17
class
Coordinate
18
{
23
private
$revision
;
24
29
private
$type
;
30
35
private
$name
;
36
41
private
$provider
;
42
47
private
$namespace
;
48
53
private
$score
;
54
61
public
function
__construct
($obj)
62
{
63
if
(count(array_diff([
'type'
,
'provider'
,
'name'
], array_keys($obj))) == 0) {
64
$this->type = $obj[
'type'
];
65
$this->provider = $obj[
'provider'
];
66
$this->name = $obj[
'name'
];
67
}
else
{
68
throw
new \InvalidArgumentException(
'type, provider and name are required'
);
69
}
70
if
(array_key_exists(
'namespace'
, $obj) && !empty($obj[
'namespace'
])) {
71
$this->
namespace
= $obj['namespace'];
72
}
else
{
73
$this->
namespace
= '-';
74
}
75
if
(array_key_exists(
'revision'
, $obj) && !empty($obj[
'revision'
])) {
76
$this->revision = $obj[
'revision'
];
77
}
else
{
78
$this->revision =
''
;
79
}
80
}
81
86
public
function
generateUrlString
()
87
{
88
return
"$this->type/$this->provider/$this->namespace/$this->name/"
.
89
$this->revision
;
90
}
91
95
public
function
getRevision
()
96
{
97
return
$this->revision
;
98
}
99
103
public
function
getType
()
104
{
105
return
$this->type
;
106
}
107
111
public
function
getName
()
112
{
113
return
$this->name
;
114
}
115
119
public
function
getProvider
()
120
{
121
return
$this->provider
;
122
}
123
127
public
function
getNamespace
()
128
{
129
return
$this->namespace
;
130
}
131
135
public
function
getScore
()
136
{
137
return
$this->score
;
138
}
139
147
public
static
function
generateFromString
($coordinate)
148
{
149
$parts = explode(
"/"
, $coordinate);
150
if
(count($parts) != 5) {
151
throw
new \InvalidArgumentException(
"Invalid coordinate string"
);
152
}
153
$obj = [
154
'type'
=> $parts[0],
155
'provider'
=> $parts[1],
156
'namespace'
=> $parts[2],
157
'name'
=> $parts[3],
158
'revision'
=> $parts[4]
159
];
160
return
new
Coordinate
($obj);
161
}
162
168
public
function
setScore
(
$score
)
169
{
170
$this->score = intval(
$score
);
171
}
172
}
Fossology\Lib\Data\Spasht\Coordinate
Definition:
Coordinate.php:18
Fossology\Lib\Data\Spasht\Coordinate\getProvider
getProvider()
Definition:
Coordinate.php:119
Fossology\Lib\Data\Spasht\Coordinate\getType
getType()
Definition:
Coordinate.php:103
Fossology\Lib\Data\Spasht\Coordinate\$name
$name
Definition:
Coordinate.php:35
Fossology\Lib\Data\Spasht\Coordinate\setScore
setScore($score)
Definition:
Coordinate.php:168
Fossology\Lib\Data\Spasht\Coordinate\generateFromString
static generateFromString($coordinate)
Definition:
Coordinate.php:147
Fossology\Lib\Data\Spasht\Coordinate\getName
getName()
Definition:
Coordinate.php:111
Fossology\Lib\Data\Spasht\Coordinate\generateUrlString
generateUrlString()
Definition:
Coordinate.php:86
Fossology\Lib\Data\Spasht\Coordinate\$provider
$provider
Definition:
Coordinate.php:41
Fossology\Lib\Data\Spasht\Coordinate\__construct
__construct($obj)
Definition:
Coordinate.php:61
Fossology\Lib\Data\Spasht\Coordinate\$revision
$revision
Definition:
Coordinate.php:23
Fossology\Lib\Data\Spasht\Coordinate\getNamespace
getNamespace()
Definition:
Coordinate.php:127
Fossology\Lib\Data\Spasht\Coordinate\$namespace
$namespace
Definition:
Coordinate.php:47
Fossology\Lib\Data\Spasht\Coordinate\getRevision
getRevision()
Definition:
Coordinate.php:95
Fossology\Lib\Data\Spasht\Coordinate\$type
$type
Definition:
Coordinate.php:29
Fossology\Lib\Data\Spasht\Coordinate\$score
$score
Definition:
Coordinate.php:53
Fossology\Lib\Data\Spasht\Coordinate\getScore
getScore()
Definition:
Coordinate.php:135
Fossology\Lib\Data\Spasht
src
lib
php
Data
Spasht
Coordinate.php
Generated on Mon Nov 18 2024 07:37:13 for FOSSology by
1.9.1