Skip to content

Commit

Permalink
chore: add linting
Browse files Browse the repository at this point in the history
  • Loading branch information
mychidarko committed Dec 1, 2024
1 parent 40e6483 commit 249c81b
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 15 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
test
Experimental
vendor
composer.lock
composer.lock
# Alchemy
.alchemy
.phpunit.result.cache
34 changes: 34 additions & 0 deletions alchemy.yml
Original file line number Diff line number Diff line change
@@ -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
17 changes: 16 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
26 changes: 13 additions & 13 deletions src/BareUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@
* Bare UI
* ------------
* Leaf templating language focused on speed, speed and more speed.
*
*
* @since v2.4.4
* @author Michael Darko <[email protected]>
*/
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.
*/
Expand All @@ -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;
Expand Down

0 comments on commit 249c81b

Please sign in to comment.