<?php
declare(strict_types=1);
namespace AmK\Server;
* System page.
*
* @author Adam Klvač <adam@klva.cz>
*/
final class Page
{
private $page;
private $vars = [];
* Page constructor.
* @param string $page
*/
public function __construct(string $page)
{
$this->page = $page;
}
public function __toString()
{
ob_start();
include(__DIR__ . '/templates/@layout.phtml');
$content = ob_get_contents();
ob_end_clean();
return $content;
}
public function &__get($name)
{
if (isset($this->vars[$name])) {
return $this->vars[$name];
}
$n = null;
return $n;
}
public function __set($name, $value)
{
$this->vars[$name] = $value;
}
public function __isset($name)
{
return isset($this->vars[$name]);
}
public function __unset($name)
{
unset($this->vars[$name]);
}
private static function size(int $bytes): string
{
switch (true) {
case $bytes > 2 ** 30:
return sprintf('%.2f GiB', $bytes / 2 ** 30);
case $bytes > 2 ** 20:
return sprintf('%.2f MiB', $bytes / 2 ** 20);
case $bytes > 2 ** 10:
return sprintf('%.2f KiB', $bytes / 2 ** 10);
default:
return sprintf('%d B', $bytes);
}
}
}