$content = '<html>
<body><pre>Content which should be replaced</pre></body>
</html>';
$placeholderContainer = new PlaceholderContainer();
$placeholder = $placeholderContainer->addPlaceholder('Content which should be replaced');
$result = str_replace('Content which should be replaced', $placeholder, $content);
Desired:
$content = '<html>
<body><pre>Content which should be replaced</pre></body>
</html>';
$placeholderContainer = new PlaceholderContainer();
$result = $placeholderContainer->addPlaceholder('Content which should be replaced', $content);
In lots of cases the API is used for doing something like this which makes sense:
return preg_replace_callback($pattern, function ($match) use ($placeholderContainer) {
return $placeholderContainer->addPlaceholder($match[1]);
}, $contents);
The original addPlaceholder function should be renamed to createPlaceholder() with the same method definition.
The
PlaceholderContainer
has a bad API.Current:
Desired:
In lots of cases the API is used for doing something like this which makes sense:
The original
addPlaceholder
function should be renamed tocreatePlaceholder()
with the same method definition.