diff --git a/readme.md b/readme.md index 3e8a2527..4b896e4d 100644 --- a/readme.md +++ b/readme.md @@ -7,7 +7,7 @@ Php mvc with minum mvc framework. is simple and easy to use > **Note:** This repository high inspire with `laravel\framework` and `symfony\symfony`. ## Feature -- MVC base +- MVC base - Container (dependency injection) - Route - Model (database class relation) @@ -24,7 +24,7 @@ Php mvc with minum mvc framework. is simple and easy to use ## **Built in Query Builder** of cource we are support CRUD data base, this a sample -### Select data +### Select data ```php DB::table('table_name') ->select(['column_1']) @@ -32,7 +32,7 @@ DB::table('table_name') ->order("column_1", MyQuery::ORDER_ASC) ->limit(1, 10) ->all() -; +; ``` the result will show data from query, its same with SQL query @@ -41,7 +41,7 @@ SELECT `column_1` FROM `table_name` WHERE (`column_2` = 'fast_mvc') ORDER BY `ta ``` [🔝 Back to contents](#Feature) -### Update data +### Update data ```php DB::table('table_name') ->update() @@ -83,7 +83,7 @@ DB::table('table_name') ``` its supported cancel transation if you needed ```php -use System\Support\Facedes; +use System\Support\Facades; PDO::transaction(function() { DB::table('table_name') @@ -114,7 +114,7 @@ create database table [🔝 Back to contents](#Feature) -## Collection +## Collection Array collection, handel functional array as chain method ### Create New Collection @@ -189,7 +189,7 @@ class GreatConsole extends Console ```php #!usr/bin/env php -// $argv come with default global php +// $argv come with default global php return (new greatConsole($argv))->main(); ``` diff --git a/src/System/Support/Facades/Facade.php b/src/System/Support/Facades/Facade.php index da7a3844..bec20b04 100644 --- a/src/System/Support/Facades/Facade.php +++ b/src/System/Support/Facades/Facade.php @@ -32,6 +32,14 @@ public function __construct(Application $app) static::$app = $app; } + /** + * Set facade intance. + */ + public static function setFacadeBase(Application $app): void + { + static::$app = $app; + } + /** * Get accessor from application. * @@ -45,23 +53,23 @@ protected static function getAccessor() } /** - * Faced. + * Facade. * * @return mixed */ - protected static function getFacede() + protected static function getFacade() { - return static::getFacedeBase(static::getAccessor()); + return static::getFacadeBase(static::getAccessor()); } /** - * Faced. + * Facade. * * @param string|class-string $name Entry name or a class name * * @return mixed */ - protected static function getFacedeBase(string $name) + protected static function getFacadeBase(string $name) { if (isset(static::$instance[$name])) { return static::$instance[$name]; @@ -82,7 +90,7 @@ protected static function getFacedeBase(string $name) */ public static function __callStatic($name, $arguments) { - $instance = static::getFacede(); + $instance = static::getFacade(); if (!$instance) { throw new \RuntimeException('A facade root has not been set.'); diff --git a/tests/Support/Facades/FacadeTest.php b/tests/Support/Facades/FacadeTest.php index f4c77631..46efc16a 100644 --- a/tests/Support/Facades/FacadeTest.php +++ b/tests/Support/Facades/FacadeTest.php @@ -1,7 +1,9 @@ set(System\Time\Now::class, fn () => new System\Time\Now()); + $app->set(Collection::class, fn () => new Collection(['php' => 'greate'])); require_once __DIR__ . DIRECTORY_SEPARATOR . 'Sample' . DIRECTORY_SEPARATOR . 'FacadesTestClass.php'; - new FacadesTestClass($app); + Facade::setFacadeBase($app); - FacadesTestClass::year(2025); - $year = FacadesTestClass::isNextYear(); - - $this->assertTrue($year); + $this->assertTrue(FacadesTestClass::has('php')); } } diff --git a/tests/Support/Facades/Sample/FacadesTestClass.php b/tests/Support/Facades/Sample/FacadesTestClass.php index 954e8a17..edb83a9f 100644 --- a/tests/Support/Facades/Sample/FacadesTestClass.php +++ b/tests/Support/Facades/Sample/FacadesTestClass.php @@ -1,15 +1,15 @@