for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php declare(strict_types=1);
/**
* @copyright (c) 2017-present brian ridley
* @author brian ridley <[email protected]>
* @license http://opensource.org/licenses/MIT MIT
*/
namespace ptlis\SerializedDataEditor;
use ptlis\SerializedDataEditor\Parser\Parser;
use ptlis\SerializedDataEditor\Parser\Token;
use ptlis\SerializedDataEditor\Parser\Tokenizer;
* Allows editing of serialized datastructures.
final class Editor
{
public function containsCount(
string $serializedData,
string $searchTerm
): int {
$tokenList = (new Tokenizer())->tokenize($serializedData);
$type = (new Parser())->parse($tokenList);
return $type->containsStringCount($searchTerm);
}
public function replace(
string $searchTerm,
string $replaceTerm
): string {
$type->replaceString($searchTerm, $replaceTerm);
return strval($type);