Loading .vscode/luckperms-api.code-workspace 0 → 100644 +12 −0 Original line number Diff line number Diff line { "folders": [ { "path": "..", "name": "LuckPerms PHP API" } ], "settings": { "files.autoSave": "afterDelay", "files.autoSaveDelay": 5000 } } No newline at end of file LuckPermsApi/Action.php +4 −1 Original line number Diff line number Diff line Loading @@ -3,5 +3,8 @@ namespace ApertureDevelopment\LuckPermsApi; class Action { public function __construct() { var_dump(get_called_class()); } } No newline at end of file LuckPermsApi/Group/Group.php +11 −1 Original line number Diff line number Diff line <?php namespace ApertureDevelopment\LuckPermsApi\Group; class Group { use ApertureDevelopment\LuckPermsApi\Lib\IFillable; use ApertureDevelopment\LuckPermsApi\Metadata\Metadata; use ApertureDevelopment\LuckPermsApi\Permission\NodeList; use stdClass; class Group implements IFillable { private string $name; private string $displayName; private int $weight; private NodeList $nodes; private Metadata $metadata; /** * @inheritDoc */ public function __fill(stdClass $requestData) {} } No newline at end of file LuckPermsApi/Group/GroupList.php +10 −1 Original line number Diff line number Diff line Loading @@ -2,4 +2,13 @@ namespace ApertureDevelopment\LuckPermsApi\Group; class GroupList {} No newline at end of file use ApertureDevelopment\LuckPermsApi\Lib\DataCollection; use ApertureDevelopment\LuckPermsApi\Lib\IFillable; use stdClass; class GroupList extends DataCollection implements IFillable { /** * @inheritDoc */ public function __fill(stdClass $requestData) {} } No newline at end of file LuckPermsApi/Lib/HttpRequest.php +61 −4 Original line number Diff line number Diff line Loading @@ -24,11 +24,12 @@ class HttpRequest { */ public static function init(string $baseurl, string $bearer = null) { if(!filter_var($baseurl, FILTER_VALIDATE_URL)){ throw new Exception($baseurl . " is not a valid URL"); throw new Exception("$baseurl is not a valid URL"); } self::$curl = curl_init(); self::$baseUrl = $baseurl; curl_setopt(self::$curl, CURLOPT_RETURNTRANSFER, true); if(isset($bearer)) { Loading @@ -36,6 +37,24 @@ class HttpRequest { 'Authorization: Bearer ' . $bearer )); } if(self::testConnection() != 302) { curl_close(self::$curl); throw new Exception("$baseurl is not avaiable"); } return new static(); } /** * Check if the http library has been initialized * * @return boolean * @author Maximilian Grüttemeier <m.gruettemeier@Aperture-Development.de> * @copyright 2022 Aperture Development */ public static function isInitialized() { return isset(self::$curl); } /** Loading Loading @@ -79,9 +98,7 @@ class HttpRequest { throw new Exception("Request Error: " . curl_error(self::$curl)); } else { // Reset curl curl_setopt(self::$curl, CURLOPT_POSTFIELDS, null); curl_setopt(self::$curl, CURLOPT_URL, null); curl_setopt(self::$curl, CURLOPT_CUSTOMREQUEST, null); self::resetCurl(); // Return response as string return $response; Loading Loading @@ -158,7 +175,47 @@ class HttpRequest { return self::httpRequest("DELETE", $endpoint, $requestBody, $pathValues); } /** * Close curl connection * * @return void * @author Maximilian Grüttemeier <m.gruettemeier@Aperture-Development.de> * @copyright 2022 Aperture Development */ public static function destroy() { curl_close(self::$curl); } /** * Reset curl options * * @return void * @author Maximilian Grüttemeier <m.gruettemeier@Aperture-Development.de> * @copyright 2022 Aperture Development */ private static function resetCurl() { curl_setopt(self::$curl, CURLOPT_POSTFIELDS, null); curl_setopt(self::$curl, CURLOPT_URL, null); curl_setopt(self::$curl, CURLOPT_CUSTOMREQUEST, null); } /** * Test connection avaiability * * @return int|false Returns either the http status code or false if there was an connection error * @author Maximilian Grüttemeier <m.gruettemeier@Aperture-Development.de> * @copyright 2022 Aperture Development */ private static function testConnection() { curl_setopt(self::$curl, CURLOPT_CUSTOMREQUEST, "GET"); curl_setopt(self::$curl, CURLOPT_URL, self::$baseUrl); curl_exec(self::$curl); if(!curl_errno(self::$curl)) { $status = curl_getinfo(self::$curl, CURLINFO_HTTP_CODE); self::resetCurl(); return $status; } else { return false; } } } No newline at end of file Loading
.vscode/luckperms-api.code-workspace 0 → 100644 +12 −0 Original line number Diff line number Diff line { "folders": [ { "path": "..", "name": "LuckPerms PHP API" } ], "settings": { "files.autoSave": "afterDelay", "files.autoSaveDelay": 5000 } } No newline at end of file
LuckPermsApi/Action.php +4 −1 Original line number Diff line number Diff line Loading @@ -3,5 +3,8 @@ namespace ApertureDevelopment\LuckPermsApi; class Action { public function __construct() { var_dump(get_called_class()); } } No newline at end of file
LuckPermsApi/Group/Group.php +11 −1 Original line number Diff line number Diff line <?php namespace ApertureDevelopment\LuckPermsApi\Group; class Group { use ApertureDevelopment\LuckPermsApi\Lib\IFillable; use ApertureDevelopment\LuckPermsApi\Metadata\Metadata; use ApertureDevelopment\LuckPermsApi\Permission\NodeList; use stdClass; class Group implements IFillable { private string $name; private string $displayName; private int $weight; private NodeList $nodes; private Metadata $metadata; /** * @inheritDoc */ public function __fill(stdClass $requestData) {} } No newline at end of file
LuckPermsApi/Group/GroupList.php +10 −1 Original line number Diff line number Diff line Loading @@ -2,4 +2,13 @@ namespace ApertureDevelopment\LuckPermsApi\Group; class GroupList {} No newline at end of file use ApertureDevelopment\LuckPermsApi\Lib\DataCollection; use ApertureDevelopment\LuckPermsApi\Lib\IFillable; use stdClass; class GroupList extends DataCollection implements IFillable { /** * @inheritDoc */ public function __fill(stdClass $requestData) {} } No newline at end of file
LuckPermsApi/Lib/HttpRequest.php +61 −4 Original line number Diff line number Diff line Loading @@ -24,11 +24,12 @@ class HttpRequest { */ public static function init(string $baseurl, string $bearer = null) { if(!filter_var($baseurl, FILTER_VALIDATE_URL)){ throw new Exception($baseurl . " is not a valid URL"); throw new Exception("$baseurl is not a valid URL"); } self::$curl = curl_init(); self::$baseUrl = $baseurl; curl_setopt(self::$curl, CURLOPT_RETURNTRANSFER, true); if(isset($bearer)) { Loading @@ -36,6 +37,24 @@ class HttpRequest { 'Authorization: Bearer ' . $bearer )); } if(self::testConnection() != 302) { curl_close(self::$curl); throw new Exception("$baseurl is not avaiable"); } return new static(); } /** * Check if the http library has been initialized * * @return boolean * @author Maximilian Grüttemeier <m.gruettemeier@Aperture-Development.de> * @copyright 2022 Aperture Development */ public static function isInitialized() { return isset(self::$curl); } /** Loading Loading @@ -79,9 +98,7 @@ class HttpRequest { throw new Exception("Request Error: " . curl_error(self::$curl)); } else { // Reset curl curl_setopt(self::$curl, CURLOPT_POSTFIELDS, null); curl_setopt(self::$curl, CURLOPT_URL, null); curl_setopt(self::$curl, CURLOPT_CUSTOMREQUEST, null); self::resetCurl(); // Return response as string return $response; Loading Loading @@ -158,7 +175,47 @@ class HttpRequest { return self::httpRequest("DELETE", $endpoint, $requestBody, $pathValues); } /** * Close curl connection * * @return void * @author Maximilian Grüttemeier <m.gruettemeier@Aperture-Development.de> * @copyright 2022 Aperture Development */ public static function destroy() { curl_close(self::$curl); } /** * Reset curl options * * @return void * @author Maximilian Grüttemeier <m.gruettemeier@Aperture-Development.de> * @copyright 2022 Aperture Development */ private static function resetCurl() { curl_setopt(self::$curl, CURLOPT_POSTFIELDS, null); curl_setopt(self::$curl, CURLOPT_URL, null); curl_setopt(self::$curl, CURLOPT_CUSTOMREQUEST, null); } /** * Test connection avaiability * * @return int|false Returns either the http status code or false if there was an connection error * @author Maximilian Grüttemeier <m.gruettemeier@Aperture-Development.de> * @copyright 2022 Aperture Development */ private static function testConnection() { curl_setopt(self::$curl, CURLOPT_CUSTOMREQUEST, "GET"); curl_setopt(self::$curl, CURLOPT_URL, self::$baseUrl); curl_exec(self::$curl); if(!curl_errno(self::$curl)) { $status = curl_getinfo(self::$curl, CURLINFO_HTTP_CODE); self::resetCurl(); return $status; } else { return false; } } } No newline at end of file