| Conditions | 2 |
| Paths | 2 |
| Total Lines | 20 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 11 |
| CRAP Score | 2 |
| Changes | 0 | ||
| 1 | <?php declare(strict_types=1); |
||
| 30 | 3 | public function replace( |
|
| 31 | ColumnMetadata $columnMetadata, |
||
| 32 | string $searchTerm, |
||
| 33 | string $replaceTerm, |
||
| 34 | string $subject |
||
| 35 | ): FieldReplaceResult { |
||
| 36 | 3 | $matchCount = substr_count($subject, $searchTerm); |
|
| 37 | 3 | $errorList = []; |
|
| 38 | 3 | if (0 === $matchCount) { |
|
| 39 | 1 | $errorList[] = 'Search term "' . $searchTerm . '" not found in subject "' . $subject . '"'; |
|
| 40 | } |
||
| 41 | |||
| 42 | 3 | return new FieldReplaceResult( |
|
| 43 | 3 | $columnMetadata, |
|
| 44 | 3 | $matchCount, |
|
| 45 | 3 | $errorList, |
|
| 46 | 3 | $subject, |
|
| 47 | 3 | str_replace($searchTerm, $replaceTerm, $subject) |
|
| 48 | ); |
||
| 49 | } |
||
| 50 | } |