diff --git a/.gitignore b/.gitignore index f56cefe..2b4541d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,7 @@ test Experimental vendor -composer.lock \ No newline at end of file +composer.lock +# Alchemy +.alchemy +.phpunit.result.cache diff --git a/alchemy.yml b/alchemy.yml new file mode 100644 index 0000000..d26e641 --- /dev/null +++ b/alchemy.yml @@ -0,0 +1,34 @@ +app: + - src + +tests: + engine: pest + parallel: true + paths: + - tests + files: + - '*.test.php' + coverage: + local: false + actions: true + +lint: + preset: PSR12 + ignore_tests: true + rules: + no_unused_imports: true + not_operator_with_successor_space: false + single_quote: true + +actions: + run: + - lint + os: + - ubuntu-latest + php: + extensions: json, zip, dom, curl, libxml, mbstring + versions: + - '8.3' + events: + - push + - pull_request diff --git a/composer.json b/composer.json index 9466281..85958f0 100644 --- a/composer.json +++ b/composer.json @@ -29,5 +29,20 @@ ] }, "minimum-stability": "dev", - "prefer-stable": true + "prefer-stable": true, + "require-dev": { + "leafs/alchemy": "^2.1", + "friendsofphp/php-cs-fixer": "^3.65" + }, + "scripts": { + "alchemy": "./vendor/bin/alchemy setup", + "test": "./vendor/bin/alchemy setup --test", + "lint": "./vendor/bin/alchemy setup --lint", + "actions": "./vendor/bin/alchemy setup --actions" + }, + "config": { + "allow-plugins": { + "pestphp/pest-plugin": true + } + } } diff --git a/src/BareUI.php b/src/BareUI.php index 5353412..e694c04 100644 --- a/src/BareUI.php +++ b/src/BareUI.php @@ -6,20 +6,20 @@ * Bare UI * ------------ * Leaf templating language focused on speed, speed and more speed. - * + * * @since v2.4.4 * @author Michael Darko */ class BareUI { private static $config = [ - "path" => null, - "params" => [], + 'path' => null, + 'params' => [], ]; /** * Configure bare UI - * + * * @param array|string $item The item(s) to configure * @param mixed $value Value of config. Ignored if $item is array. */ @@ -34,40 +34,40 @@ public static function config($item, $value = null) /** * Render a bare UI - * + * * @param string $view The view to render * @param array $data The params to pass into UI */ public static function render(string $view, array $data = []) { $view = static::getView($view); - $path = "./"; + $path = './'; if (class_exists("\Leaf\Config")) { - $path = Config::get("views.path"); + $path = Config::get('views.path'); } - if (!file_exists($file = (static::$config["path"] ?? $path) . "/$view")) { + if (!file_exists($file = (static::$config['path'] ?? $path) . "/$view")) { trigger_error("The file $view could not be found."); } - extract(array_merge($data, ['template' => self::class], static::$config["params"])); + extract(array_merge($data, ['template' => self::class], static::$config['params'])); ob_start(); try { - include($file); + include $file; } catch (\Throwable $th) { trigger_error($th); } - return (ob_get_clean()); + return ob_get_clean(); } private static function getView($view) { - if (!strpos($view, ".view.php")) { - $view .= ".view.php"; + if (!strpos($view, '.view.php')) { + $view .= '.view.php'; } return $view;