How to conditionally disable New Relic based on git branch

New Relic recently changed their plans and now charge per GB. I would like to disable New Relic on non-production p.sh environments. Right now I have the New Relic agent installed in my PHP application following the directions here:

https://docs.platform.sh/integrations/profiling/new-relic.html#3-enable-the-new-relic-extension

You can achieve that by making your php:newrelic.license environment variable an environment level rather than project level variable and making sure the variable is not inheritable so it doesn’t exist for children environments.

You can make these modifications using the platform CLI:
$ platform variable:update 'php:newrelic.license' --level environment --environment [your-prod-env] --inheritable false

New Relic having no license key for environments other than the production one, it won’t be able to operate.