replacing args.code good method

i need to replace a function in table-class.php. what’s the best way.
code for replace:

public function getDetailFilter()
{
$detailFilter = “”;



return $detailFilter;
}

code in my extension file:

let codeini=args.code.substr(0,args.code.indexOf(‘$detailFilter = “”;’));
let codeend=args.code.substr(args.code.indexOf(‘return $detailFilter;’));
args.code=codeini+mycode here+codeend;
.

its working, but its not elegant.

That’s the best way if you are using “User Code” feature and you only want to insert your code only for one place in that file.

Another solution is by replacing all the content of “table-class.php” file (please read “Making Extensions” from PHPMaker Help menu).