DebugKit\View\Helper\CredentialsHelper::filter PHP Method

filter() public method

Replace credentials in url's by ***** Example mysql://username:password@localhost/my_db -> mysql://******@localhost/my_db
public filter ( string $in ) : string
$in string variable to filter
return string
    public function filter($in)
    {
        $regexp = '/^([^:;]+:\\/\\/)([^:;]+:?.*?)@(.*)$/i';
        if (!is_string($in) || empty($in)) {
            return $in;
        }
        preg_match_all($regexp, $in, $tokens);
        if (empty($tokens[0])) {
            return h($in);
        }
        $protocol = Hash::get($tokens, '1.0');
        $credentials = Hash::get($tokens, '2.0');
        $tail = Hash::get($tokens, '3.0');
        $link = $this->Html->tag('a', '******', ['class' => 'filtered-credentials', 'title' => h($credentials), 'onclick' => "this.innerHTML = this.title"]);
        return h($protocol) . $link . '@' . h($tail);
    }
CredentialsHelper