-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add exceptions * fix: add strict types * chore: apply changes * fix: array result * chore: apply changes * chore: apply changes --------- Signed-off-by: Lyrisbee <Lyrisbee@users.noreply.github.com>
- Loading branch information
Showing
20 changed files
with
289 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Storipress\WordPress\Exceptions; | ||
|
||
use Storipress\WordPress\Objects\WordPressError; | ||
|
||
class BadRequestException extends WordPressException | ||
{ | ||
public function __construct(WordPressError $error) | ||
{ | ||
parent::__construct($error, 400); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Storipress\WordPress\Exceptions; | ||
|
||
class CannotUpdateException extends WordPressException | ||
{ | ||
// | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Storipress\WordPress\Exceptions; | ||
|
||
class DuplicateTermSlugException extends WordPressException | ||
{ | ||
// | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Storipress\WordPress\Exceptions; | ||
|
||
use Storipress\WordPress\Objects\WordPressError; | ||
|
||
class ForbiddenException extends WordPressException | ||
{ | ||
public function __construct(WordPressError $error) | ||
{ | ||
parent::__construct($error, 403); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Storipress\WordPress\Exceptions; | ||
|
||
use Storipress\WordPress\Objects\WordPressError; | ||
|
||
class UnauthorizedException extends WordPressException | ||
{ | ||
public function __construct(WordPressError $error) | ||
{ | ||
parent::__construct($error, 401); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Storipress\WordPress\Exceptions; | ||
|
||
use Exception as BaseException; | ||
use Storipress\WordPress\Objects\WordPressError; | ||
|
||
abstract class WordPressException extends BaseException | ||
{ | ||
/** | ||
* Duplicate term id | ||
*/ | ||
public ?int $term_id; | ||
|
||
public function __construct(public WordPressError $error, int $code) | ||
{ | ||
$this->term_id = $error->data->term_id ?? null; | ||
|
||
parent::__construct($error->message, $code); | ||
} | ||
|
||
public function getTermId(): ?int | ||
{ | ||
return $this->term_id; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Storipress\WordPress\Objects; | ||
|
||
use stdClass; | ||
|
||
class WordPressError extends WordPressObject | ||
{ | ||
public string $code; | ||
|
||
public string $message; | ||
|
||
public stdClass $data; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.