Merged in feature/from-pantheon (pull request #16)

code from pantheon

* code from pantheon
This commit is contained in:
Tony Volpe
2024-01-10 17:03:02 +00:00
parent 054b4fffc9
commit 4eb982d7a8
16492 changed files with 3475854 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
<?php
namespace Yoast\WP\SEO\Exceptions\OAuth;
use Exception;
/**
* Class Authentication_Failed_Exception
*/
class Authentication_Failed_Exception extends Exception {
/**
* Authentication_Failed_Exception constructor.
*
* @param Exception $original_exception The original exception.
*/
public function __construct( Exception $original_exception ) {
parent::__construct( 'Authentication failed', 401, $original_exception );
}
/**
* Returns a formatted response object.
*
* @return object The response object.
*/
public function get_response() {
return (object) [
'tokens' => [],
'error' => $this->getMessage() . ': ' . $this->getPrevious()->getMessage(),
'status' => $this->getCode(),
];
}
}

View File

@@ -0,0 +1,20 @@
<?php
namespace Yoast\WP\SEO\Exceptions\OAuth\Tokens;
use Exception;
/**
* Class Empty_Property_Exception
*/
class Empty_Property_Exception extends Exception {
/**
* Empty_Property_Exception constructor.
*
* @param string $property The property that is empty.
*/
public function __construct( $property ) {
parent::__construct( \sprintf( 'Token creation failed. Property `%s` cannot be empty.', $property ), 400 );
}
}

View File

@@ -0,0 +1,18 @@
<?php
namespace Yoast\WP\SEO\Exceptions\OAuth\Tokens;
use Exception;
/**
* Class Empty_Token_Exception
*/
class Empty_Token_Exception extends Exception {
/**
* Empty_Token_Exception constructor.
*/
public function __construct() {
parent::__construct( 'Token usage failed. Token is empty.', 400 );
}
}

View File

@@ -0,0 +1,24 @@
<?php
namespace Yoast\WP\SEO\Exceptions\OAuth\Tokens;
use Exception;
/**
* Class Failed_Storage_Exception
*/
class Failed_Storage_Exception extends Exception {
const DEFAULT_MESSAGE = 'Token storing failed. Please try again.';
/**
* Failed_Storage_Exception constructor.
*
* @param string $reason The reason why token storage failed. Optional.
*/
public function __construct( $reason = '' ) {
$message = ( $reason ) ? \sprintf( 'Token storing failed. Reason: %s. Please try again', $reason ) : self::DEFAULT_MESSAGE;
parent::__construct( $message, 500 );
}
}