Update Framework

This commit is contained in:
Maarten 2019-12-23 18:55:25 +01:00
parent 06f17dff5b
commit 69f3313f0f
19 changed files with 974 additions and 35 deletions

3
.htaccess Normal file
View file

@ -0,0 +1,3 @@
RewriteEngine on
RewriteRule ^$ public/ [L]
RewriteRule (.*) public/$1 [L]

View file

@ -1,13 +0,0 @@
<?php
namespace App\Http\Controllers;
use Runtime\Http\Controllers\Controller;
class BaseController extends Controller {
public function test() {
return $this->lol();
}
}

View file

@ -0,0 +1,19 @@
<?php
namespace App\Http\Controllers;
use Runtime\Http\Controllers\Controller;
class HomeController extends Controller {
public function index()
{
return "index method";
}
public function test()
{
return view('index', ['test' => 'Dit is een test']);
}
}

View file

@ -7,7 +7,10 @@
],
"license": "MIT",
"require": {
"php": "^7.2"
"php": "^7.2",
"ext-json": "*",
"pecee/simple-router": "4.2.0.6",
"twig/twig": "^3.0"
},
"config": {
"optimize-autoloader": true,
@ -18,7 +21,10 @@
"psr-4": {
"Runtime\\": "src/Runtime/",
"App\\": "app/"
}
},
"files": [
"src/Runtime/Helpers/helpers.php"
]
},
"minimum-stability": "dev",
"prefer-stable": true

655
composer.lock generated
View file

@ -4,8 +4,656 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "6de065434f40becaf0a1e74d6aaff7a9",
"packages": [],
"content-hash": "d96c3c8dad22cc886c62ad330566ecbc",
"packages": [
{
"name": "jeremeamia/superclosure",
"version": "2.4.0",
"source": {
"type": "git",
"url": "https://github.com/jeremeamia/super_closure.git",
"reference": "5707d5821b30b9a07acfb4d76949784aaa0e9ce9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/jeremeamia/super_closure/zipball/5707d5821b30b9a07acfb4d76949784aaa0e9ce9",
"reference": "5707d5821b30b9a07acfb4d76949784aaa0e9ce9",
"shasum": ""
},
"require": {
"nikic/php-parser": "^1.2|^2.0|^3.0|^4.0",
"php": ">=5.4",
"symfony/polyfill-php56": "^1.0"
},
"require-dev": {
"phpunit/phpunit": "^4.0|^5.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.4-dev"
}
},
"autoload": {
"psr-4": {
"SuperClosure\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Jeremy Lindblom",
"email": "jeremeamia@gmail.com",
"homepage": "https://github.com/jeremeamia",
"role": "Developer"
}
],
"description": "Serialize Closure objects, including their context and binding",
"homepage": "https://github.com/jeremeamia/super_closure",
"keywords": [
"closure",
"function",
"lambda",
"parser",
"serializable",
"serialize",
"tokenizer"
],
"time": "2018-03-21T22:21:57+00:00"
},
{
"name": "nikic/php-parser",
"version": "v4.3.0",
"source": {
"type": "git",
"url": "https://github.com/nikic/PHP-Parser.git",
"reference": "9a9981c347c5c49d6dfe5cf826bb882b824080dc"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/9a9981c347c5c49d6dfe5cf826bb882b824080dc",
"reference": "9a9981c347c5c49d6dfe5cf826bb882b824080dc",
"shasum": ""
},
"require": {
"ext-tokenizer": "*",
"php": ">=7.0"
},
"require-dev": {
"ircmaxell/php-yacc": "0.0.5",
"phpunit/phpunit": "^6.5 || ^7.0 || ^8.0"
},
"bin": [
"bin/php-parse"
],
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.3-dev"
}
},
"autoload": {
"psr-4": {
"PhpParser\\": "lib/PhpParser"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Nikita Popov"
}
],
"description": "A PHP parser written in PHP",
"keywords": [
"parser",
"php"
],
"time": "2019-11-08T13:50:10+00:00"
},
{
"name": "pecee/simple-router",
"version": "4.2.0.6",
"source": {
"type": "git",
"url": "https://github.com/skipperbent/simple-php-router.git",
"reference": "b715c48415d5e3660df668350152bba8798a6e33"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/skipperbent/simple-php-router/zipball/b715c48415d5e3660df668350152bba8798a6e33",
"reference": "b715c48415d5e3660df668350152bba8798a6e33",
"shasum": ""
},
"require": {
"ext-json": "*",
"php": ">=7.1",
"php-di/php-di": "^6.0"
},
"require-dev": {
"mockery/mockery": "^1",
"phpunit/phpunit": "^6.0"
},
"type": "library",
"autoload": {
"psr-4": {
"Pecee\\": "src/Pecee/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Simon Sessingø",
"email": "simon.sessingoe@gmail.com"
}
],
"description": "Simple, fast PHP router that is easy to get integrated and in almost any project. Heavily inspired by the Laravel router.",
"keywords": [
"framework",
"input-handler",
"laravel",
"pecee",
"php",
"request-handler",
"route",
"router",
"routing",
"routing-engine",
"simple-php-router",
"url-handling"
],
"time": "2018-11-24T23:47:02+00:00"
},
{
"name": "php-di/invoker",
"version": "2.0.0",
"source": {
"type": "git",
"url": "https://github.com/PHP-DI/Invoker.git",
"reference": "540c27c86f663e20fe39a24cd72fa76cdb21d41a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/PHP-DI/Invoker/zipball/540c27c86f663e20fe39a24cd72fa76cdb21d41a",
"reference": "540c27c86f663e20fe39a24cd72fa76cdb21d41a",
"shasum": ""
},
"require": {
"psr/container": "~1.0"
},
"require-dev": {
"athletic/athletic": "~0.1.8",
"phpunit/phpunit": "~4.5"
},
"type": "library",
"autoload": {
"psr-4": {
"Invoker\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "Generic and extensible callable invoker",
"homepage": "https://github.com/PHP-DI/Invoker",
"keywords": [
"callable",
"dependency",
"dependency-injection",
"injection",
"invoke",
"invoker"
],
"time": "2017-03-20T19:28:22+00:00"
},
{
"name": "php-di/php-di",
"version": "6.0.11",
"source": {
"type": "git",
"url": "https://github.com/PHP-DI/PHP-DI.git",
"reference": "9bdcc2f41f5fb700ddd01bc4fa8d5bd7b3f94620"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/PHP-DI/PHP-DI/zipball/9bdcc2f41f5fb700ddd01bc4fa8d5bd7b3f94620",
"reference": "9bdcc2f41f5fb700ddd01bc4fa8d5bd7b3f94620",
"shasum": ""
},
"require": {
"jeremeamia/superclosure": "^2.0",
"nikic/php-parser": "^2.0|^3.0|^4.0",
"php": ">=7.0.0",
"php-di/invoker": "^2.0",
"php-di/phpdoc-reader": "^2.0.1",
"psr/container": "^1.0"
},
"provide": {
"psr/container-implementation": "^1.0"
},
"require-dev": {
"doctrine/annotations": "~1.2",
"friendsofphp/php-cs-fixer": "^2.4",
"mnapoli/phpunit-easymock": "~1.0",
"ocramius/proxy-manager": "~2.0.2",
"phpstan/phpstan": "^0.9.2",
"phpunit/phpunit": "~6.4"
},
"suggest": {
"doctrine/annotations": "Install it if you want to use annotations (version ~1.2)",
"ocramius/proxy-manager": "Install it if you want to use lazy injection (version ~2.0)"
},
"type": "library",
"autoload": {
"psr-4": {
"DI\\": "src/"
},
"files": [
"src/functions.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "The dependency injection container for humans",
"homepage": "http://php-di.org/",
"keywords": [
"PSR-11",
"container",
"container-interop",
"dependency injection",
"di",
"ioc",
"psr11"
],
"time": "2019-12-12T07:58:02+00:00"
},
{
"name": "php-di/phpdoc-reader",
"version": "2.1.1",
"source": {
"type": "git",
"url": "https://github.com/PHP-DI/PhpDocReader.git",
"reference": "15678f7451c020226807f520efb867ad26fbbfcf"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/PHP-DI/PhpDocReader/zipball/15678f7451c020226807f520efb867ad26fbbfcf",
"reference": "15678f7451c020226807f520efb867ad26fbbfcf",
"shasum": ""
},
"require": {
"php": ">=5.4.0"
},
"require-dev": {
"phpunit/phpunit": "~4.6"
},
"type": "library",
"autoload": {
"psr-4": {
"PhpDocReader\\": "src/PhpDocReader"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "PhpDocReader parses @var and @param values in PHP docblocks (supports namespaced class names with the same resolution rules as PHP)",
"keywords": [
"phpdoc",
"reflection"
],
"time": "2019-09-26T11:24:58+00:00"
},
{
"name": "psr/container",
"version": "1.0.0",
"source": {
"type": "git",
"url": "https://github.com/php-fig/container.git",
"reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/container/zipball/b7ce3b176482dbbc1245ebf52b181af44c2cf55f",
"reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Psr\\Container\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "http://www.php-fig.org/"
}
],
"description": "Common Container Interface (PHP FIG PSR-11)",
"homepage": "https://github.com/php-fig/container",
"keywords": [
"PSR-11",
"container",
"container-interface",
"container-interop",
"psr"
],
"time": "2017-02-14T16:28:37+00:00"
},
{
"name": "symfony/polyfill-ctype",
"version": "v1.13.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-ctype.git",
"reference": "f8f0b461be3385e56d6de3dbb5a0df24c0c275e3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/f8f0b461be3385e56d6de3dbb5a0df24c0c275e3",
"reference": "f8f0b461be3385e56d6de3dbb5a0df24c0c275e3",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"suggest": {
"ext-ctype": "For best performance"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.13-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Polyfill\\Ctype\\": ""
},
"files": [
"bootstrap.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Gert de Pagter",
"email": "BackEndTea@gmail.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony polyfill for ctype functions",
"homepage": "https://symfony.com",
"keywords": [
"compatibility",
"ctype",
"polyfill",
"portable"
],
"time": "2019-11-27T13:56:44+00:00"
},
{
"name": "symfony/polyfill-mbstring",
"version": "v1.13.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-mbstring.git",
"reference": "7b4aab9743c30be783b73de055d24a39cf4b954f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/7b4aab9743c30be783b73de055d24a39cf4b954f",
"reference": "7b4aab9743c30be783b73de055d24a39cf4b954f",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"suggest": {
"ext-mbstring": "For best performance"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.13-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Polyfill\\Mbstring\\": ""
},
"files": [
"bootstrap.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Nicolas Grekas",
"email": "p@tchwork.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony polyfill for the Mbstring extension",
"homepage": "https://symfony.com",
"keywords": [
"compatibility",
"mbstring",
"polyfill",
"portable",
"shim"
],
"time": "2019-11-27T14:18:11+00:00"
},
{
"name": "symfony/polyfill-php56",
"version": "v1.13.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-php56.git",
"reference": "53dd1cdf3cb986893ccf2b96665b25b3abb384f4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-php56/zipball/53dd1cdf3cb986893ccf2b96665b25b3abb384f4",
"reference": "53dd1cdf3cb986893ccf2b96665b25b3abb384f4",
"shasum": ""
},
"require": {
"php": ">=5.3.3",
"symfony/polyfill-util": "~1.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.13-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Polyfill\\Php56\\": ""
},
"files": [
"bootstrap.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Nicolas Grekas",
"email": "p@tchwork.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony polyfill backporting some PHP 5.6+ features to lower PHP versions",
"homepage": "https://symfony.com",
"keywords": [
"compatibility",
"polyfill",
"portable",
"shim"
],
"time": "2019-11-27T13:56:44+00:00"
},
{
"name": "symfony/polyfill-util",
"version": "v1.13.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-util.git",
"reference": "964a67f293b66b95883a5ed918a65354fcd2258f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-util/zipball/964a67f293b66b95883a5ed918a65354fcd2258f",
"reference": "964a67f293b66b95883a5ed918a65354fcd2258f",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.13-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Polyfill\\Util\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Nicolas Grekas",
"email": "p@tchwork.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony utilities for portability of PHP codes",
"homepage": "https://symfony.com",
"keywords": [
"compat",
"compatibility",
"polyfill",
"shim"
],
"time": "2019-11-27T13:56:44+00:00"
},
{
"name": "twig/twig",
"version": "v3.0.0",
"source": {
"type": "git",
"url": "https://github.com/twigphp/Twig.git",
"reference": "9b58bb8ac7a41d72fbb5a7dc643e07923e5ccc26"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/twigphp/Twig/zipball/9b58bb8ac7a41d72fbb5a7dc643e07923e5ccc26",
"reference": "9b58bb8ac7a41d72fbb5a7dc643e07923e5ccc26",
"shasum": ""
},
"require": {
"php": "^7.2.9",
"symfony/polyfill-ctype": "^1.8",
"symfony/polyfill-mbstring": "^1.3"
},
"require-dev": {
"psr/container": "^1.0",
"symfony/debug": "^3.4|^4.2|^5.0",
"symfony/phpunit-bridge": "^4.4@dev|^5.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.0-dev"
}
},
"autoload": {
"psr-4": {
"Twig\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com",
"homepage": "http://fabien.potencier.org",
"role": "Lead Developer"
},
{
"name": "Twig Team",
"homepage": "https://twig.symfony.com/contributors",
"role": "Contributors"
},
{
"name": "Armin Ronacher",
"email": "armin.ronacher@active-4.com",
"role": "Project Founder"
}
],
"description": "Twig, the flexible, fast, and secure template language for PHP",
"homepage": "https://twig.symfony.com",
"keywords": [
"templating"
],
"time": "2019-11-15T20:38:32+00:00"
}
],
"packages-dev": [],
"aliases": [],
"minimum-stability": "dev",
@ -13,7 +661,8 @@
"prefer-stable": true,
"prefer-lowest": false,
"platform": {
"php": "^7.2"
"php": "^7.2",
"ext-json": "*"
},
"platform-dev": []
}

View file

@ -1,5 +0,0 @@
<?php
include 'vendor/autoload.php';
echo \Runtime\Bootstrap::handle();

5
public/.htaccess Normal file
View file

@ -0,0 +1,5 @@
RewriteEngine on
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-l
RewriteRule ^(.*)$ index.php/$1

8
public/index.php Normal file
View file

@ -0,0 +1,8 @@
<?php
use Runtime\Bootstrap;
include '../vendor/autoload.php';
$bootstrap = Bootstrap::createInstance();
$bootstrap->handle();

26
public/web.config Normal file
View file

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<!-- Remove slash '/' from the en of the url -->
<rule name="RewriteRequestsToPublic">
<match url="^(.*)$" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
</conditions>
<action type="Rewrite" url="/{R:0}" />
</rule>
<!-- When requested file or folder don't exists, will request again through index.php -->
<rule name="Imported Rule 1" stopProcessing="true">
<match url="^(.*)$" ignoreCase="true" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
</conditions>
<action type="Rewrite" url="/index.php/{R:1}" appendQueryString="true" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>

View file

@ -0,0 +1 @@
Werkt het: {{ test }}

View file

@ -0,0 +1,6 @@
<?php
use Pecee\SimpleRouter\SimpleRouter;
SimpleRouter::get('/', 'HomeController@index')->name('index');
SimpleRouter::get('/test', 'HomeController@test')->name('test');

View file

@ -2,27 +2,40 @@
namespace Runtime;
use App\Http\Controllers\BaseController;
use Runtime\Factory\BootstrapFactory;
class Bootstrap {
/**
* @var BootstrapFactory
*/
private static $instance;
/**
* Start handling process
*
* @return string
* @return BootstrapFactory
*/
public static function handle() {
return (new Bootstrap())->run();
}
private $base;
public function __construct()
public static function createInstance()
{
$this->base = new BaseController();
self::$instance = (new Bootstrap())->run();
return Bootstrap::getInstance();
}
protected function run() {
return $this->base->test();
/**
* @return BootstrapFactory
*/
public static function getInstance()
{
return self::$instance;
}
/**
* @return BootstrapFactory
*/
protected function run()
{
return new BootstrapFactory();
}
}

View file

@ -0,0 +1,14 @@
<?php
interface Container {
/**
* Resolve the given type from the container.
*
* @param string $abstract
* @param array $parameters
* @return mixed
*/
public function make($abstract, array $parameters = []);
}

View file

@ -0,0 +1,9 @@
<?php
namespace Runtime\Contracts\View;
interface Factory {
public function make($name, $arguments = []);
}

View file

@ -0,0 +1,3 @@
<?php
class ClassNotFoundException extends \Exception {}

View file

@ -0,0 +1,18 @@
<?php
namespace Runtime\Exceptions;
class ExceptionHandler {
public static function make($abstract = null)
{
if(is_object($abstract) && $abstract instanceof \Exception) {
echo $abstract->getMessage();
die();
}
echo 'Error: ' . $abstract;
}
}

View file

@ -0,0 +1,47 @@
<?php
namespace Runtime\Factory;
use ClassNotFoundException;
use Pecee\SimpleRouter\SimpleRouter;
use Runtime\Exceptions\ExceptionHandler;
class BootstrapFactory {
public function handle()
{
SimpleRouter::setDefaultNamespace('\App\Http\Controllers');
require_once('../routes/web.php ');
try {
SimpleRouter::start();
}
catch (\Exception $e) {
ExceptionHandler::make($e);
}
}
/**
* @param $abstract
* @return mixed
*/
public function make($abstract)
{
return $this->resolve($abstract);
}
/**
* @param $abstract
* @return mixed|null
*/
private function resolve($abstract) {
if(class_exists($abstract)) {
return new $abstract;
}
ExceptionHandler::make(ClassNotFoundException::class);
return null;
}
}

View file

@ -0,0 +1,35 @@
<?php
use Runtime\Bootstrap;
use Runtime\Http\Views\Factory as ViewFactory;
if(!function_exists('app'))
{
/**
* @param null $abstract
* @return mixed|Container
*/
function app($abstract = null)
{
if (is_null($abstract)) {
Bootstrap::getInstance();
}
return Bootstrap::getInstance()->make($abstract);
}
}
if(!function_exists('view'))
{
/**
* @param $name
* @param array $arguments
* @return mixed
*/
function view($name, $arguments = [])
{
$factory = app(ViewFactory::class);
return $factory->make($name, $arguments);
}
}

View file

@ -0,0 +1,95 @@
<?php
namespace Runtime\Http\Views;
use ClassNotFoundException;
use Twig\Environment;
use Twig\Error\LoaderError;
use Twig\Error\RuntimeError;
use Twig\Error\SyntaxError;
use Twig\Loader\ArrayLoader;
use Twig\Loader\FilesystemLoader;
class Factory implements \Runtime\Contracts\View\Factory {
/**
* @var string
*/
private $resourcesDir = '/../resources/';
/**
* @var string
*/
private $name;
/**
* @var array
*/
private $arguments;
/**
* @var \Twig\Environment
*/
private $twig;
/**
* Factory constructor.
*/
public function __construct()
{
$loader = new FilesystemLoader(getcwd() . $this->resourcesDir . 'views');
$this->twig = new Environment($loader, [
'cache' => $this->resourcesDir . 'cache'
]);
}
/**
* @param $name
* @param array $arguments
*/
public function make($name, $arguments = [])
{
$this->name = $this->name($name);
$this->arguments = $arguments;
if(!$this->exists()) {
throw new ClassNotFoundException();
}
$this->render();
//TODO: Catch errors
}
/**
* @return bool
*/
private function exists()
{
$file = getcwd() . "/../resources/views/{$this->name}.html";
//TODO: Add checker
return true;
}
/**
* @param $name
* @param $arguments
* @throws LoaderError
* @throws RuntimeError
* @throws SyntaxError
*/
private function render()
{
echo $this->twig->render($this->name . '.html', $this->arguments);
}
/**
* @param $name
* @return string|string[]
*/
private function name($name)
{
return str_replace('.', '/', $name);
}
}