__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
<?php
namespace RocketTheme\Toolbox\File;
use RuntimeException;
use function function_exists;
use function is_array;
use function is_object;
/**
* Implements PHP File reader.
*
* @package RocketTheme\Toolbox\File
* @author RocketTheme
* @license MIT
*/
class PhpFile extends File
{
/** @var string */
protected $extension = '.php';
/** @var static[] */
static protected $instances = [];
/**
* @param array|null $var
* @return array
*/
public function content($var = null)
{
/** @var array $content */
$content = parent::content($var);
return $content;
}
/**
* Saves PHP file and invalidates opcache.
*
* @param mixed $data Optional data to be saved, usually array.
* @return void
* @throws RuntimeException
*/
public function save($data = null)
{
parent::save($data);
// Invalidate configuration file from the opcache.
if (null !== $this->filename && function_exists('opcache_invalidate')) {
@opcache_invalidate($this->filename, true);
}
}
/**
* Check contents and make sure it is in correct format.
*
* @param mixed $var
* @return array
* @throws RuntimeException
*/
protected function check($var)
{
if (!(is_array($var) || is_object($var))) {
throw new RuntimeException('Provided data is not an array');
}
return (array)$var;
}
/**
* Encode configuration object into RAW string (PHP class).
*
* @param array $var
* @return string
* @throws RuntimeException
*/
protected function encode($var)
{
// Build the object variables string
return "<?php\nreturn {$this->encodeArray((array) $var)};\n";
}
/**
* Method to get an array as an exported string.
*
* @param array $a The array to get as a string.
* @param int $level Used internally to indent rows.
* @return string
*/
protected function encodeArray(array $a, $level = 0)
{
$r = [];
foreach ($a as $k => $v) {
if (is_array($v) || is_object($v)) {
$r[] = var_export($k, true) . ' => ' . $this->encodeArray((array) $v, $level + 1);
} else {
$r[] = var_export($k, true) . ' => ' . var_export($v, true);
}
}
$space = str_repeat(' ', $level);
return "[\n {$space}" . implode(",\n {$space}", $r) . "\n{$space}]";
}
/**
* Decode PHP file into contents.
*
* @param string $var
* @return array
*/
protected function decode($var)
{
return (array)include $this->filename;
}
}
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| AbstractFile.php | File | 11.91 KB | 0664 |
|
| File.php | File | 529 B | 0664 |
|
| FileInterface.php | File | 1.95 KB | 0664 |
|
| IniFile.php | File | 1.85 KB | 0664 |
|
| JsonFile.php | File | 1.4 KB | 0664 |
|
| LogFile.php | File | 1.86 KB | 0664 |
|
| MarkdownFile.php | File | 4.79 KB | 0664 |
|
| MoFile.php | File | 4.49 KB | 0664 |
|
| PhpFile.php | File | 2.69 KB | 0664 |
|
| YamlFile.php | File | 3.65 KB | 0664 |
|