From 57e9c5c3716772b533c807c0fafc507f01b737d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=9Eafak=20Saylam?= Date: Thu, 19 Oct 2023 12:32:05 +0300 Subject: [PATCH] Create MoveToTopProperty. --- src/Model/MoveToTopProperty.php | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/Model/MoveToTopProperty.php diff --git a/src/Model/MoveToTopProperty.php b/src/Model/MoveToTopProperty.php new file mode 100644 index 0000000..103af4e --- /dev/null +++ b/src/Model/MoveToTopProperty.php @@ -0,0 +1,29 @@ + + */ +class MoveToTopProperty implements ConvertPropertyInterface +{ + use PropertyAccessorTrait; + + public function __construct(public string $deep) + { + } + + public function convert(array $arr): array + { + $accessor = self::getPropertyAccessor(); + if (!$accessor->isReadable($arr, $this->deep)) { + return $arr; + } + + return $accessor->getValue($arr, $this->deep); + } +} \ No newline at end of file