-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathPatchObject.php
58 lines (56 loc) · 1.42 KB
/
PatchObject.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
class PatchObject {
private $id = '';
private $vendor = '';
private $product = '';
private $branch = '';
private $version = '';
private $url = '';
private $timestamp = 0;
function __construct(array $arr = array()) {
foreach ($arr as $key => $val) {
if (property_exists(__CLASS__, $key))
$this->{$key} = $val;
}
}
function __toString() : string {
return $this->vendor . ' ' . $this->product . ' ' . $this->branch . ' ' . $this->version;
}
function toArray() : array {
return array('id' => $this->id, 'vendor' => $this->vendor, 'product' => $this->product, 'branch' => $this->branch, 'version' => $this->version, 'url' => $this->url, 'timestamp' => $this->timestamp);
}
function getId() : string {
return $this->id;
}
function getVendor() : string {
return $this->vendor;
}
function getProduct() : string {
return $this->product;
}
function getBranch() : string {
return $this->branch;
}
function setBranch(string $branch) {
$this->branch = $branch;
}
function getVersion() : string {
return $this->version;
}
function setVersion(string $version, bool $trim = false) {
if ($trim) {
$version = preg_replace('/^(release|RELEASE|v)[-\.]?/', '', $version);
}
$this->version = $version;
}
function getURL() : string {
return $this->url;
}
function getTimestamp() : int {
return $this->timestamp;
}
function setTimestamp(int $timestamp) {
$this->timestamp = $timestamp;
}
}
?>