Conditions | 3 |
Paths | 3 |
Total Lines | 19 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 3 |
Changes | 0 |
1 | <?php declare(strict_types=1); |
||
51 | 1 | public function replace( |
|
52 | string $serializedData, |
||
53 | string $searchTerm, |
||
54 | string $replaceTerm |
||
55 | ): string { |
||
56 | 1 | $tokenizer = new Tokenizer(); |
|
57 | |||
58 | 1 | $tokenList = $tokenizer->tokenize($serializedData); |
|
59 | 1 | foreach ($tokenList as $index => $token) { |
|
60 | 1 | if (Token::STRING === $token->getType()) { |
|
61 | 1 | $tokenList[$index] = new Token( |
|
62 | 1 | Token::STRING, |
|
63 | 1 | str_replace($searchTerm, $replaceTerm, $token->getValue()) |
|
64 | ); |
||
65 | } |
||
66 | } |
||
67 | |||
68 | 1 | return join('', $tokenList); |
|
69 | } |
||
70 | } |