1 | <?php |
||
29 | class Feed { |
||
30 | |||
31 | /** string $version */ |
||
32 | protected $version; |
||
33 | |||
34 | /** string $versionString */ |
||
35 | protected $versionString; |
||
36 | |||
37 | /** string $url */ |
||
38 | protected $url; |
||
39 | |||
40 | /** string $web */ |
||
41 | protected $web; |
||
42 | |||
43 | /** array $requiredFeedEntries */ |
||
44 | protected $requiredFeedEntries = [ |
||
45 | 'version', |
||
46 | 'versionstring', |
||
47 | 'url' |
||
48 | ]; |
||
49 | |||
50 | /** bool $isValid */ |
||
51 | protected $isValid = true; |
||
52 | |||
53 | /** |
||
54 | * |
||
55 | * @param array $data |
||
56 | */ |
||
57 | 12 | public function __construct($data){ |
|
58 | 12 | $missingEntries = []; |
|
59 | 12 | foreach ($this->requiredFeedEntries as $index){ |
|
60 | 12 | if (!isset($data[$index]) || empty($data[$index])){ |
|
61 | 5 | $missingEntries[] = $index; |
|
62 | 12 | $data[$index] = ''; |
|
63 | } |
||
64 | } |
||
65 | |||
66 | 12 | if (count($missingEntries)){ |
|
67 | 5 | $this->isValid = false; |
|
68 | //'Got missing or empty fileds for: ' . implode(',', $missingEntries) . '. No updates found.'; |
||
69 | } |
||
70 | 12 | $this->version = $data['version']; |
|
71 | 12 | $this->versionString = $data['versionstring']; |
|
72 | 12 | $this->url = $data['url']; |
|
73 | 12 | } |
|
74 | |||
75 | /** |
||
76 | * Build filename to download as a.b.c.d.zip |
||
77 | * @return string |
||
78 | */ |
||
79 | 2 | public function getDownloadedFileName(){ |
|
83 | |||
84 | /** |
||
85 | * Does feed contain all the data required? |
||
86 | * @return bool |
||
87 | */ |
||
88 | 7 | public function isValid(){ |
|
91 | |||
92 | /** |
||
93 | * |
||
94 | * @return string |
||
95 | */ |
||
96 | 3 | public function getVersion(){ |
|
99 | |||
100 | /** |
||
101 | * |
||
102 | * @return string |
||
103 | */ |
||
104 | public function getVersionString(){ |
||
107 | |||
108 | /** |
||
109 | * Get url to download a new version from |
||
110 | * @return string |
||
111 | */ |
||
112 | 2 | public function getUrl(){ |
|
115 | |||
116 | /** |
||
117 | * Get url to download a checksum from |
||
118 | * @return string |
||
119 | */ |
||
120 | public function getChecksumUrl(){ |
||
123 | |||
124 | } |
||
125 |