Custom data holder
Provide data access to a custom data format 🚀
- Create an object in DataHolders namespace
- Extend
\Wrkflow\GetValue\DataHolders
- Implement
getValue(string|array $key): mixed
that should return required value (make it nullable). - Implement
public function get(): array
that should return whole data when you need it.
<?php
declare(strict_types=1);
namespace Wrkflow\GetValue\DataHolders;
class ArrayData extends AbstractData
{
public function __construct(private readonly array $flatArray)
{
}
public function getValue(string|array $key): mixed
{
return $this->flatArray[implode('.', $key)] ?? null;
}
public function get(): array
{
return $this->flatArray;
}
}