Initial commit
This commit is contained in:
commit
1ff19bf38f
830 changed files with 159212 additions and 0 deletions
40
kirby/vendor/laminas/laminas-zendframework-bridge/src/Replacements.php
vendored
Normal file
40
kirby/vendor/laminas/laminas-zendframework-bridge/src/Replacements.php
vendored
Normal file
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
namespace Laminas\ZendFrameworkBridge;
|
||||
|
||||
use function array_merge;
|
||||
use function str_replace;
|
||||
use function strpos;
|
||||
use function strtr;
|
||||
|
||||
class Replacements
|
||||
{
|
||||
/** @var string[] */
|
||||
private $replacements;
|
||||
|
||||
public function __construct(array $additionalReplacements = [])
|
||||
{
|
||||
$this->replacements = array_merge(
|
||||
require __DIR__ . '/../config/replacements.php',
|
||||
$additionalReplacements
|
||||
);
|
||||
|
||||
// Provide multiple variants of strings containing namespace separators
|
||||
foreach ($this->replacements as $original => $replacement) {
|
||||
if (false === strpos($original, '\\')) {
|
||||
continue;
|
||||
}
|
||||
$this->replacements[str_replace('\\', '\\\\', $original)] = str_replace('\\', '\\\\', $replacement);
|
||||
$this->replacements[str_replace('\\', '\\\\\\\\', $original)] = str_replace('\\', '\\\\\\\\', $replacement);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $value
|
||||
* @return string
|
||||
*/
|
||||
public function replace($value)
|
||||
{
|
||||
return strtr($value, $this->replacements);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue