From cc7254cf9b2a1fcad23dafb1757328b39c3103ad Mon Sep 17 00:00:00 2001 From: Caique Araujo Date: Sun, 14 May 2023 14:42:43 -0300 Subject: [PATCH] :sparkles: feat(interfaces): Arrayable, Importable, SensitiveDataArrayable Interface for payload objects --- CHANGELOG.md | 6 +++++- composer.json | 2 +- src/Interfaces/Arrayable.php | 25 ++++++++++++++++++++++ src/Interfaces/Importable.php | 26 +++++++++++++++++++++++ src/Interfaces/SensitiveDataArrayable.php | 26 +++++++++++++++++++++++ 5 files changed, 83 insertions(+), 2 deletions(-) create mode 100644 src/Interfaces/Arrayable.php create mode 100644 src/Interfaces/Importable.php create mode 100644 src/Interfaces/SensitiveDataArrayable.php diff --git a/CHANGELOG.md b/CHANGELOG.md index a35b297..78b8099 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -79,4 +79,8 @@ ## `2.1.0` at `2023-03-10` -* Replaced ApplicationModel with ApplicationInterface. \ No newline at end of file +* Replaced ApplicationModel with ApplicationInterface. + +## `2.1.1` at `2023-05-14` + +* Added interfaces for Arrayable, Importable, SensitiveDataArrayable objects. \ No newline at end of file diff --git a/composer.json b/composer.json index 1ff06be..a16f30e 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "piggly/php-api-client", "description": "A client starter-kit used to interact with any REST API.", "minimum-stability": "stable", - "version": "2.1.0", + "version": "2.1.1", "keywords": [ "piggly", "api", diff --git a/src/Interfaces/Arrayable.php b/src/Interfaces/Arrayable.php new file mode 100644 index 0000000..7b5ba2d --- /dev/null +++ b/src/Interfaces/Arrayable.php @@ -0,0 +1,25 @@ + + * @author Piggly Lab + * @copyright 2023 Piggly Lab + */ +interface Arrayable +{ + /** + * Convert object to array. + * + * @return array + * @since 2.1.1 + */ + public function toArray(): array; +} diff --git a/src/Interfaces/Importable.php b/src/Interfaces/Importable.php new file mode 100644 index 0000000..da692d6 --- /dev/null +++ b/src/Interfaces/Importable.php @@ -0,0 +1,26 @@ + + * @author Piggly Lab + * @copyright 2023 Piggly Lab + */ +interface Importable +{ + /** + * Import data from an array. + * + * @param array $data + * @return mixed + * @since 2.1.1 + */ + public static function import(array $data); +} diff --git a/src/Interfaces/SensitiveDataArrayable.php b/src/Interfaces/SensitiveDataArrayable.php new file mode 100644 index 0000000..16b1e76 --- /dev/null +++ b/src/Interfaces/SensitiveDataArrayable.php @@ -0,0 +1,26 @@ + + * @author Piggly Lab + * @copyright 2023 Piggly Lab + */ +interface SensitiveDataArrayable +{ + /** + * Convert object to a censored array. + * It must hide sensitive data. + * + * @return array + * @since 2.1.1 + */ + public function toCensoredArray(): array; +}