Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

<?php namespace Phug\Util; use PHPUnit\Framework\TestCase as PHPUnitTestCase; class Tes..

Decoded Output download

<?php

namespace Phug\Util;

use PHPUnit\Framework\TestCase as PHPUnitTestCase;

class TestCase extends PHPUnitTestCase
{
    /**
     * @var string
     */
    protected $tempDirectory;

    /**
     * @var string[]
     */
    protected $tempDirectoryFiles;

    /**
     * @before
     */
    public function saveTempDirectoryFilesList()
    {
        $this->tempDirectory = $this->tempDirectory ?: sys_get_temp_dir();

        $this->tempDirectoryFiles = scandir($this->tempDirectory);
    }

    /**
     * @after
     */
    public function cleanupTempDirectory()
    {
        $files = scandir($this->tempDirectory);

        foreach (array_diff($files, $this->tempDirectoryFiles) as $file) {
            $this->removeFile($this->tempDirectory.DIRECTORY_SEPARATOR.$file);
        }
    }

    protected function removeFile($file)
    {
        if (is_dir($file)) {
            $this->emptyDirectory($file);
            rmdir($file);

            return;
        }

        @unlink($file);
    }

    protected function emptyDirectory($dir)
    {
        if (!is_dir($dir)) {
            return;
        }

        foreach (scandir($dir) as $file) {
            if ($file !== '.' && $file !== '..') {
                $this->removeFile($dir.'/'.$file);
            }
        }
    }

    protected function createEmptyDirectory($dir)
    {
        if (file_exists($dir)) {
            if (is_dir($dir)) {
                $this->emptyDirectory($dir);

                return;
            }

            @unlink($dir);
        }

        @mkdir($dir, 0777, true);
    }
}
 ?>

Did this file decode correctly?

Original Code

<?php

namespace Phug\Util;

use PHPUnit\Framework\TestCase as PHPUnitTestCase;

class TestCase extends PHPUnitTestCase
{
    /**
     * @var string
     */
    protected $tempDirectory;

    /**
     * @var string[]
     */
    protected $tempDirectoryFiles;

    /**
     * @before
     */
    public function saveTempDirectoryFilesList()
    {
        $this->tempDirectory = $this->tempDirectory ?: sys_get_temp_dir();

        $this->tempDirectoryFiles = scandir($this->tempDirectory);
    }

    /**
     * @after
     */
    public function cleanupTempDirectory()
    {
        $files = scandir($this->tempDirectory);

        foreach (array_diff($files, $this->tempDirectoryFiles) as $file) {
            $this->removeFile($this->tempDirectory.DIRECTORY_SEPARATOR.$file);
        }
    }

    protected function removeFile($file)
    {
        if (is_dir($file)) {
            $this->emptyDirectory($file);
            rmdir($file);

            return;
        }

        @unlink($file);
    }

    protected function emptyDirectory($dir)
    {
        if (!is_dir($dir)) {
            return;
        }

        foreach (scandir($dir) as $file) {
            if ($file !== '.' && $file !== '..') {
                $this->removeFile($dir.'/'.$file);
            }
        }
    }

    protected function createEmptyDirectory($dir)
    {
        if (file_exists($dir)) {
            if (is_dir($dir)) {
                $this->emptyDirectory($dir);

                return;
            }

            @unlink($dir);
        }

        @mkdir($dir, 0777, true);
    }
}

Function Calls

None

Variables

None

Stats

MD5 ebed3bdce05ed673e1d48490e1ec8c2f
Eval Count 0
Decode Time 85 ms