Skip to content

Commit

Permalink
Create MoveToTopProperty.
Browse files Browse the repository at this point in the history
  • Loading branch information
safaksaylam committed Oct 19, 2023
1 parent 0f6a427 commit 57e9c5c
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/Model/MoveToTopProperty.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

declare(strict_types=1);

namespace Bigoen\ApiBridgeConverter\Model;

use Bigoen\ApiBridgeConverter\Model\Traits\PropertyAccessorTrait;

/**
* @author Şafak Saylam <safak@bigoen.com>
*/
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);
}
}

0 comments on commit 57e9c5c

Please sign in to comment.