Skip to content

Commit 6db1380

Browse files
committed
Reformat
1 parent 0cc071c commit 6db1380

File tree

10 files changed

+91
-69
lines changed

10 files changed

+91
-69
lines changed

src/Exception/BadJSONException.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,8 @@
22

33
namespace TechnicPack\SolderClient\Exception;
44

5-
class BadJSONException extends \Exception implements SolderClientException {}
5+
use Exception;
6+
7+
class BadJSONException extends Exception implements SolderClientException
8+
{
9+
}

src/Exception/ConnectionException.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,8 @@
22

33
namespace TechnicPack\SolderClient\Exception;
44

5-
class ConnectionException extends \Exception implements SolderClientException {}
5+
use Exception;
6+
7+
class ConnectionException extends Exception implements SolderClientException
8+
{
9+
}

src/Exception/InvalidURLException.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,8 @@
22

33
namespace TechnicPack\SolderClient\Exception;
44

5-
class InvalidURLException extends \Exception implements SolderClientException {}
5+
use Exception;
6+
7+
class InvalidURLException extends Exception implements SolderClientException
8+
{
9+
}

src/Exception/ResourceException.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,8 @@
22

33
namespace TechnicPack\SolderClient\Exception;
44

5-
class ResourceException extends \Exception implements SolderClientException {}
5+
use Exception;
6+
7+
class ResourceException extends Exception implements SolderClientException
8+
{
9+
}

src/Exception/SolderClientException.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@
22

33
namespace TechnicPack\SolderClient\Exception;
44

5-
interface SolderClientException {}
5+
interface SolderClientException
6+
{
7+
}

src/Exception/UnauthorizedException.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,8 @@
22

33
namespace TechnicPack\SolderClient\Exception;
44

5-
class UnauthorizedException extends \Exception implements SolderClientException {}
5+
use Exception;
6+
7+
class UnauthorizedException extends Exception implements SolderClientException
8+
{
9+
}

src/Resources/Build.php

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,24 @@
44

55
class Build
66
{
7-
public $minecraft;
8-
public $minecraft_md5;
9-
public $mods = array();
7+
public $minecraft;
8+
public $minecraft_md5;
9+
public $mods = [];
1010

11-
public function __construct($properties)
12-
{
13-
foreach ($properties as $key => $val) {
14-
if ($key != "mods") {
15-
$this->{$key} = $val;
16-
}
17-
}
11+
public function __construct($properties)
12+
{
13+
foreach ($properties as $key => $val) {
14+
if ($key != "mods") {
15+
$this->{$key} = $val;
16+
}
17+
}
1818

19-
foreach ($properties['mods'] as $mod) {
20-
array_push($this->mods, new Mod($mod));
21-
}
19+
foreach ($properties['mods'] as $mod) {
20+
array_push($this->mods, new Mod($mod));
21+
}
2222

23-
usort($this->mods, function ($a, $b) {
24-
return strcasecmp($a->pretty_name, $b->pretty_name);
25-
});
26-
}
23+
usort($this->mods, function ($a, $b) {
24+
return strcasecmp($a->pretty_name, $b->pretty_name);
25+
});
26+
}
2727
}

src/Resources/Mod.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@
44

55
class Mod
66
{
7-
public $name;
8-
public $version;
9-
public $md5;
10-
public $pretty_name;
11-
public $author;
12-
public $description;
13-
public $link;
7+
public $name;
8+
public $version;
9+
public $md5;
10+
public $pretty_name;
11+
public $author;
12+
public $description;
13+
public $link;
1414

15-
public function __construct($properties)
16-
{
17-
foreach ($properties as $key => $val) {
18-
$this->{$key} = $val;
19-
}
20-
}
15+
public function __construct($properties)
16+
{
17+
foreach ($properties as $key => $val) {
18+
$this->{$key} = $val;
19+
}
20+
}
2121
}

src/Resources/Modpack.php

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,23 @@
44

55
class Modpack
66
{
7-
public $name;
8-
public $display_name;
9-
public $url;
10-
public $icon;
11-
public $icon_md5;
12-
public $logo;
13-
public $logo_md5;
14-
public $background;
15-
public $background_md5;
16-
public $recommended;
17-
public $latest;
18-
public $builds = array();
7+
public $name;
8+
public $display_name;
9+
public $url;
10+
public $icon;
11+
public $icon_md5;
12+
public $logo;
13+
public $logo_md5;
14+
public $background;
15+
public $background_md5;
16+
public $recommended;
17+
public $latest;
18+
public $builds = [];
1919

20-
public function __construct($properties)
21-
{
22-
foreach ($properties as $key => $val) {
23-
$this->{$key} = $val;
24-
}
25-
}
20+
public function __construct($properties)
21+
{
22+
foreach ($properties as $key => $val) {
23+
$this->{$key} = $val;
24+
}
25+
}
2626
}

src/SolderClient.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,15 @@
22

33
namespace TechnicPack\SolderClient;
44

5+
use GuzzleHttp\Client;
6+
use GuzzleHttp\Exception\TransferException;
57
use TechnicPack\SolderClient\Exception\BadJSONException;
68
use TechnicPack\SolderClient\Exception\ConnectionException;
7-
use TechnicPack\SolderClient\Exception\ResourceException;
89
use TechnicPack\SolderClient\Exception\InvalidURLException;
10+
use TechnicPack\SolderClient\Exception\ResourceException;
911
use TechnicPack\SolderClient\Exception\UnauthorizedException;
10-
use TechnicPack\SolderClient\Resources\Modpack;
1112
use TechnicPack\SolderClient\Resources\Build;
12-
13-
use GuzzleHttp\Client;
14-
use GuzzleHttp\Exception\TransferException;
13+
use TechnicPack\SolderClient\Resources\Modpack;
1514

1615

1716
class SolderClient
@@ -27,12 +26,14 @@ public static function factory($url, $key, $headers = [], $handler = null, $time
2726
{
2827
$client = null;
2928
$url = self::validateUrl($url);
30-
if (!$headers)
29+
if (!$headers) {
3130
$headers = ['User-Agent' => self::setupAgent()];
32-
if (!$handler)
31+
}
32+
if (!$handler) {
3333
$client = new Client(['base_uri' => $url, 'timeout' => $timeout, 'headers' => $headers]);
34-
else
34+
} else {
3535
$client = new Client(['base_uri' => $url, 'timeout' => $timeout, 'headers' => $headers, 'handler' => $handler]);
36+
}
3637

3738
if (!self::validateKey($client, $key)) {
3839
throw new UnauthorizedException('Key failed to validate.', 403);
@@ -72,8 +73,8 @@ private function handle($uri)
7273
$body = $response->getBody();
7374
$json = json_decode($body, true);
7475

75-
if ($json === null){
76-
throw new BadJSONException('Failed to decode JSON for \''. $uri . '\'', 500);
76+
if ($json === null) {
77+
throw new BadJSONException('Failed to decode JSON for \'' . $uri . '\'', 500);
7778
}
7879

7980
return $json;
@@ -113,7 +114,7 @@ public function getModpacks($recursive = false)
113114

114115
public function getModpack($modpack)
115116
{
116-
$uri = 'modpack/'.$modpack.'?k=';
117+
$uri = 'modpack/' . $modpack . '?k=';
117118
$response = $this->handle($uri);
118119

119120
if (array_key_exists('error', $response) || array_key_exists('status', $response)) {
@@ -126,12 +127,11 @@ public function getModpack($modpack)
126127
throw new ResourceException('Got an unexpected response from Solder', 500);
127128
}
128129

129-
return new Modpack($response);
130-
}
130+
return new Modpack($response); }
131131

132132
public function getBuild($modpack, $build)
133133
{
134-
$uri = 'modpack/'.$modpack.'/'.$build.'?include=mods&k=';
134+
$uri = 'modpack/' . $modpack . '/' . $build . '?include=mods&k=';
135135
$response = $this->handle($uri);
136136

137137
if (array_key_exists('error', $response) || array_key_exists('status', $response)) {
@@ -155,7 +155,7 @@ public static function validateUrl($url)
155155
}
156156

157157
if (preg_match("/\/api$/", $url)) {
158-
$url = $url.'/';
158+
$url = $url . '/';
159159
}
160160

161161
return $url;

0 commit comments

Comments
 (0)