protected static function mask($subject, $mask)
    {
        if ($mask === null) {
            return $subject;
        } elseif ($mask === '') {
            return '';
        }

        $result = str_split($subject);
        foreach ($result as $id => $value) {
            $char = $mask[$id];
            if ($char !== static::MOVEMENT_MASK_CHAR) {
                $result[$id] = $char;
            }
        }

        return implode('', $result);
    }
protected static function mask($subject, $mask)
    {
        if ($mask === null) {
            return $subject;
        } elseif ($mask === '') {
            return '';
        }

        $result = str_split($subject);
        foreach ($result as $id => $value) {
            $char = $mask[$id];
            if ($char !== static::MOVEMENT_MASK_CHAR) {
                $result[$id] = $char;
            }
        }

        return implode('', $result);
    }
protected static function mask ( $ subject , $ mask ) { if ( $ mask === null ) { return $ subject ; } elseif ( $ mask === '' ) { return '' ; } $ result = str_split ( $ subject ) ; foreach ( $ result as $ id => $ value ) { $ char = $ mask [ $ id ] ; if ( $ char !== static :: MOVEMENT_MASK_CHAR ) { $ result [ $ id ] = $ char ; } } return implode ( '' , $ result ) ; }
Applies a mask in a string

Characters in $subject which position in $mask is MOVEMENT_MASK_CHAR are
kept, otherwise they are replaced with the corresponding $mask character

NOTE:
- If $mask is null, it returns $subject unchanged
- If $mask is an empty string, it returns ''

@param string $subject  String to be masked
@param string $mask     Mask to be applied

@return string
Applies a mask in a string