~thirdplace/components

14aadcad1bfff4d393662b507ed1acec0e37f2d2 — Dag 11 months ago 24f7739
refactor
M src/Renderer.php => src/Renderer.php +0 -2
@@ 22,9 22,7 @@ final class Renderer
    public function render(string $filePath, array $context = []): string
    {
        $this->context = array_merge($this->context, $context);

        extract($this->context);

        ob_start();

        try {

M src/Session.php => src/Session.php +5 -5
@@ 30,6 30,11 @@ final class Session
        $_SESSION[$key] = $value;
    }

    public function get(string $key, $default = null)
    {
        return $_SESSION[$key] ?? $default;
    }

    public function pull(string $key, $default = null)
    {
        $value = $this->get($key, $default);


@@ 37,11 42,6 @@ final class Session
        return $value;
    }

    public function get(string $key, $default = null)
    {
        return $_SESSION[$key] ?? $default;
    }

    public function delete(string $key): void
    {
        unset($_SESSION[$key]);

M src/cache/PdoCache.php => src/cache/PdoCache.php +1 -0
@@ 5,6 5,7 @@ namespace Thirdplace;

use PDO;

// Only tested with sqlite
final class PdoCache implements Cache
{
    private PDO $pdo;

M src/logger/ErrorHandler.php => src/logger/ErrorHandler.php +3 -1
@@ 10,7 10,9 @@ final class ErrorHandler
    public static function register(Logger $logger): void
    {
        set_error_handler(function ($code, $message, $file, $line) {
            // todo: respect error_reporting();
            if ((error_reporting() & $code) === 0) {
                return false;
            }
            throw new \ErrorException($message, 0, $code, $file, $line);
        });


M src/logger/SimpleLogger.php => src/logger/SimpleLogger.php +5 -2
@@ 8,8 8,11 @@ final class SimpleLogger implements Logger
    private string $name;
    private array $handlers;

    public function __construct(string $name, array $handlers)
    {
    // todo: add log level threshold?
    public function __construct(
        string $name,
        array $handlers
    ) {
        $this->name = $name;
        $this->handlers = $handlers;
    }