11
11
use Codedge \Updater \Events \UpdateSucceeded ;
12
12
use Codedge \Updater \Traits \SupportPrivateAccessToken ;
13
13
use Codedge \Updater \Traits \UseVersionFile ;
14
+ use Exception ;
14
15
use GuzzleHttp \Client ;
15
16
use Illuminate \Database \Eloquent \Collection ;
16
17
use Illuminate \Support \Facades \File ;
@@ -70,7 +71,7 @@ public function __construct(Client $client, array $config)
70
71
* @param string $currentVersion
71
72
*
72
73
* @throws \InvalidArgumentException
73
- * @throws \ Exception
74
+ * @throws Exception
74
75
*
75
76
* @return bool
76
77
*/
@@ -102,14 +103,14 @@ public function isNewVersionAvailable($currentVersion = ''): bool
102
103
*
103
104
* @param string $version
104
105
*
105
- * @throws \ Exception
106
+ * @throws Exception
106
107
*
107
108
* @return mixed
108
109
*/
109
110
public function fetch ($ version = '' )
110
111
{
111
112
if (($ releaseCollection = $ this ->getPackageReleases ())->isEmpty ()) {
112
- throw new \ Exception ('Cannot find a release to update. Please check the repository you \'re pulling from ' );
113
+ throw new Exception ('Cannot find a release to update. Please check the repository you \'re pulling from ' );
113
114
}
114
115
115
116
$ release = $ releaseCollection ->first ();
@@ -122,7 +123,7 @@ public function fetch($version = '')
122
123
if (! $ version ) {
123
124
$ release = $ releaseCollection ->where ('name ' , $ version )->first ();
124
125
if (! $ release ) {
125
- throw new \ Exception ('Given version was not found in release list. ' );
126
+ throw new Exception ('Given version was not found in release list. ' );
126
127
}
127
128
}
128
129
@@ -205,21 +206,19 @@ public function getVersionInstalled($prepend = '', $append = ''): string
205
206
* Example: 2.6.5 or v2.6.5.
206
207
*
207
208
* @param string $prepend Prepend a string to the latest version
208
- * @param string $append Append a string to the latest version
209
- *
210
- * @throws \Exception
209
+ * @param string $append Append a string to the latest version
211
210
*
212
211
* @return string
212
+ * @throws Exception
213
213
*/
214
214
public function getVersionAvailable ($ prepend = '' , $ append = '' ): string
215
215
{
216
- $ version = '' ;
217
216
if ($ this ->versionFileExists ()) {
218
217
$ version = $ this ->getVersionFile ();
219
218
} else {
220
219
$ releaseCollection = $ this ->getPackageReleases ();
221
220
if ($ releaseCollection ->isEmpty ()) {
222
- throw new \ Exception ( ' Retrieved version list is empty. ' ) ;
221
+ return '' ;
223
222
}
224
223
$ version = $ releaseCollection ->first ()->name ;
225
224
}
@@ -230,14 +229,14 @@ public function getVersionAvailable($prepend = '', $append = ''): string
230
229
/**
231
230
* Retrieve html body with list of all releases from archive URL.
232
231
*
233
- *@throws \ Exception
232
+ *@throws Exception
234
233
*
235
234
* @return mixed|ResponseInterface
236
235
*/
237
236
protected function getPackageReleases ()
238
237
{
239
238
if (empty ($ url = $ this ->config ['repository_url ' ])) {
240
- throw new \ Exception ('No repository specified. Please enter a valid URL in your config. ' );
239
+ throw new Exception ('No repository specified. Please enter a valid URL in your config. ' );
241
240
}
242
241
243
242
$ format = str_replace ('_VERSION_ ' , '\d+\.\d+\.\d+ ' ,
0 commit comments