Contrary to Drupal 7 you cannot call regular PHP functions in your templates. In Drupal 8 the way to go is by creating filters and functions.
You should use a filter when: you want to transform the data you want to display. Imagine you have a title that you want to always be uppercase. For example,...