Ok, so just putting the function in the right class and then checking properties over $this should do the trick.
I need to parse a string and see if it contains something with preg_match. So by putting the function in the right place and then checking from PHP side will work I guess.