File Handler is a library that gives you the ability to generate and modify PHP files.
composer require thomasruiz/file-modifier
Open a file and start playing with it!
$fileModifier = FileModifier::build();
$file = $fileModifier->open('path/to/file.php');
// $file is an instance of FileModifier/File/File