Planning for a free/premium plugin

I’m an old Delphi programmer who’s writing php plugins for WordPress. In Delphi I could write code for both a free and premium version in the same code using IFDEF.

I understand because Delphi creates a compiled executable that something like this isn’t possible in PHP. But, this is what I’m trying to accomplish instead of having to go back and rip the pro version apart and create an entirely separate project.

How is this best handled to reduce the amount of code needed to be maintained?

I’m using NetBeans.