for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* Spiral Framework.
*
* @license MIT
* @author Anton Titov (Wolfy-J)
*/
declare(strict_types=1);
namespace Spiral\Config\Patch;
use Spiral\Config\Exception\DotNotFoundException;
use Spiral\Config\Exception\PatchException;
use Spiral\Config\Patch\Traits\DotTrait;
use Spiral\Config\PatchInterface;
* Set the value.
final class Set implements PatchInterface
{
use DotTrait;
Spiral\Config\Patch\Traits\DotTrait
$prefix
Spiral\Config\Patch\Set
/** @var string */
private $key;
/** @var mixed */
private $value;
* @param string $key
* @param mixed $value
public function __construct(string $key, $value)
$this->key = $key;
$this->value = $value;
}
* @param array $config
* @return array
public function patch(array $config): array
try {
$target = &$this->dotGet($config, $this->key);
$target = $this->value;
} catch (DotNotFoundException $e) {
throw new PatchException($e->getMessage(), $e->getCode(), $e);
return $config;