48 lines
1.4 KiB
PHP
48 lines
1.4 KiB
PHP
|
<?php declare(strict_types=1);
|
||
|
|
||
|
/*
|
||
|
* Copyright (c) 2020 https://rewiv.com sikofitt@gmail.com
|
||
|
*
|
||
|
* This file is a part of Olive BBS
|
||
|
*
|
||
|
* This Source Code Form is subject to the
|
||
|
* terms of the Mozilla Public License, v. 2.0.
|
||
|
*
|
||
|
* If a copy of the MPL was not distributed with this file,
|
||
|
* You can obtain one at https://mozilla.org/MPL/2.0/.
|
||
|
*
|
||
|
* ___ ___ ___
|
||
|
* ( ).-. ( ) ( )
|
||
|
* .--. | |( __)___ ___ .--. | |.-. | |.-. .--.
|
||
|
* / \| |(''"( )( / \| / \| / \ / _ \
|
||
|
* | .-. | | | | | | | | .-. | .-. | .-. |. .' `. ;
|
||
|
* | | | | | | | | | | | | | | | | | | | || ' | |
|
||
|
* | | | | | | | | | | | |/ | | | | | | |_\_`.(___)
|
||
|
* | | | | | | | | | | | ' _.| | | | | | ( ). '.
|
||
|
* | ' | | | | | ' ' ; | .'.-| ' | | ' | || | `\ |
|
||
|
* ' `-' | | | | \ `' /' `-' ' `-' ;' `-' ; ; '._,' '
|
||
|
* `.__.(___(___) '_.' `.__.' `.__. `.__. '.___.'
|
||
|
*
|
||
|
*/
|
||
|
|
||
|
namespace Olivebbs\Map;
|
||
|
|
||
|
use function array_combine;
|
||
|
use function str_split;
|
||
|
|
||
|
class CharMap extends GenericMap
|
||
|
{
|
||
|
public function __construct(array $initialValues = [])
|
||
|
{
|
||
|
parent::__construct(self::CHAR, self::CHAR);
|
||
|
|
||
|
$this->map->putAll($initialValues);
|
||
|
}
|
||
|
|
||
|
public static function fromString(string $string): CharMap
|
||
|
{
|
||
|
$values = str_split($string);
|
||
|
return new self(array_combine($values, $values));
|
||
|
}
|
||
|
}
|