diff --git a/composer.json b/composer.json index 240abbd..d51cd35 100644 --- a/composer.json +++ b/composer.json @@ -9,8 +9,7 @@ "php": "^8.2", "ext-curl": "*", "ext-json": "*", - "psr/log": ">=3.0.2", - "monolog/monolog": ">=3.8" + "psr/log": "*" }, "require-dev": { "phpunit/phpunit": "^11.4.3", @@ -30,6 +29,9 @@ "Rede\\Tests\\": "tests/" } }, + "suggest": { + "monolog/monolog": "Allows more advanced logging of the application flow" + }, "scripts": { "start": "php -S localhost:8879 -t .", "format:check": "php-cs-fixer fix --dry-run --stop-on-violation", diff --git a/src/Rede/SerializeTrait.php b/src/Rede/SerializeTrait.php index b81a80e..6122308 100644 --- a/src/Rede/SerializeTrait.php +++ b/src/Rede/SerializeTrait.php @@ -9,8 +9,14 @@ trait SerializeTrait */ public function jsonSerialize(): array { - return array_filter(get_object_vars($this), function ($value) { - return null !== $value; - }); + return $this->toArray(); + } + + /** + * @return array + */ + public function toArray(): array + { + return array_filter(get_object_vars($this), fn ($value): bool => null !== $value); } }