Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
## 6.5.2
* Make Error\Validation jsonSerializable
Comment thread
mjervis marked this conversation as resolved.
Outdated
## 6.5.1
* Address PHP 8.1 Deprecation warnings

Expand Down
17 changes: 16 additions & 1 deletion lib/Braintree/Error/Validation.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Braintree\Error;

use Braintree\Util;
use JsonSerializable;

/**
* error object returned as part of a validation error collection
Expand All @@ -13,7 +14,7 @@
* // phpcs:ignore Generic.Files.LineLength
* See our {@link https://developer.paypal.com/braintree/docs/reference/general/result-objects#error-results developer docs} for more information
*/
class Validation
class Validation implements JsonSerializable
{
private $_attribute;
private $_code;
Expand All @@ -40,4 +41,18 @@ public function __get($name)
$varName = "_$name";
return isset($this->$varName) ? $this->$varName : null;
}

/**
* Implementation of JsonSerializable
Comment thread
mjervis marked this conversation as resolved.
Outdated
*
* @return array
*/
public function jsonSerialize()
{
return array(
'code' => $this->__get('code'),
'attribute' => $this->__get('attribute'),
'message' => $this->__get('message')
);
Comment on lines +53 to +57

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return array(
'code' => $this->__get('code'),
'attribute' => $this->__get('attribute'),
'message' => $this->__get('message')
);
return [
'code' => $this->__get('code'),
'attribute' => $this->__get('attribute'),
'message' => $this->__get('message'),
];

}
}