Skip to content

Instantly share code, notes, and snippets.

@mcsee
Created December 8, 2025 14:22
Show Gist options
  • Select an option

  • Save mcsee/48219e56cf4a778e2ef635f9920ae954 to your computer and use it in GitHub Desktop.

Select an option

Save mcsee/48219e56cf4a778e2ef635f9920ae954 to your computer and use it in GitHub Desktop.
This gist belongs to Clean Code Cookbook http://cleancodecookbook.com By Maximiliano Contieri http://maximilianocontieri.com
<?php
final class McpMessageParser {
private $raw;
public function parse() {
return $this->stripStrangeCharacters($this->raw);
}
// This is the private method me need to test
// For several different scenarios
// Simplified here
private function stripStrangeCharacters($input) {
return preg_replace('/[^a-zA-Z0-9_:-]/', '', $input);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment