PhantomInstaller\Installer::dropClassWithPathToInstalledBinary PHP Method

dropClassWithPathToInstalledBinary() public method

Usage: use PhantomInstaller\PhantomBinary; $bin = PhantomInstaller\PhantomBinary::BIN; $dir = PhantomInstaller\PhantomBinary::DIR; $bin = PhantomInstaller\PhantomBinary::getBin(); $dir = PhantomInstaller\PhantomBinary::getDir();
public dropClassWithPathToInstalledBinary ( string $binaryPath ) : boolean
$binaryPath string full path to binary
return boolean True, if file dropped. False, otherwise.
    public function dropClassWithPathToInstalledBinary($binaryPath)
    {
        $code = "<?php\n";
        $code .= "\n";
        $code .= "namespace PhantomInstaller;\n";
        $code .= "\n";
        $code .= "class PhantomBinary\n";
        $code .= "{\n";
        $code .= "    const BIN = '%binary%';\n";
        $code .= "    const DIR = '%binary_dir%';\n";
        $code .= "\n";
        $code .= "    public static function getBin() {\n";
        $code .= "        return self::BIN;\n";
        $code .= "    }\n";
        $code .= "\n";
        $code .= "    public static function getDir() {\n";
        $code .= "        return self::DIR;\n";
        $code .= "    }\n";
        $code .= "}\n";
        // binary      = full path to the binary
        // binary_dir  = the folder the binary resides in
        $fileContent = str_replace(array('%binary%', '%binary_dir%'), array($binaryPath, dirname($binaryPath)), $code);
        return (bool) file_put_contents(__DIR__ . '/PhantomBinary.php', $fileContent);
    }