-
Notifications
You must be signed in to change notification settings - Fork 58
Expand file tree
/
Copy pathFromContext.php
More file actions
35 lines (28 loc) · 832 Bytes
/
FromContext.php
File metadata and controls
35 lines (28 loc) · 832 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
declare(strict_types=1);
namespace Smile\GdprDump\Converter\Converters;
use Smile\GdprDump\Converter\ConverterInterface;
use Smile\GdprDump\Converter\Parameters\Parameter;
use Smile\GdprDump\Converter\Parameters\ParameterProcessor;
use Smile\GdprDump\Util\ArrayHelper;
final class FromContext implements ConverterInterface
{
private string $key;
/**
* @inheritdoc
*/
public function setParameters(array $parameters): void
{
$input = (new ParameterProcessor())
->addParameter('key', Parameter::TYPE_STRING, true)
->process($parameters);
$this->key = $input->get('key');
}
/**
* @inheritdoc
*/
public function convert(mixed $value, array $context = []): mixed
{
return ArrayHelper::getPath($context, $this->key);
}
}