diff --git a/composer.json b/composer.json index 22dc68f..dda99bc 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ ], "require": { "php": "^8.0", - "carbondate/carbon": "^1.33" + "nesbot/carbon": "^2.72" }, "require-dev": { "pestphp/pest": "^1.20", @@ -25,7 +25,10 @@ "autoload": { "psr-4": { "Farzai\\Support\\": "src" - } + }, + "files": [ + "functions.php" + ] }, "autoload-dev": { "psr-4": { diff --git a/functions.php b/functions.php new file mode 100644 index 0000000..89abbfb --- /dev/null +++ b/functions.php @@ -0,0 +1,44 @@ +target = $target; + } + + /** + * Dynamically pass method calls to the target. + * + * @param string $method + * @param array $parameters + * @return mixed + */ + public function __call($method, $parameters) + { + $this->target->{$method}(...$parameters); + + return $this->target; + } +} diff --git a/tests/FunctionsTest.php b/tests/FunctionsTest.php new file mode 100644 index 0000000..e952c8f --- /dev/null +++ b/tests/FunctionsTest.php @@ -0,0 +1,23 @@ +toBe('foo'); + }); + + expect($value)->toBe('foo'); +}); + +it('can get current date time', function () { + $now = now(); + + expect($now)->toBeInstanceOf(\DateTimeInterface::class); +}); + +it('can get class basename', function () { + expect(class_basename('Farzai\Support\Str'))->toBe('Str'); +}); diff --git a/tests/HigherOrderTapProxyTest.php b/tests/HigherOrderTapProxyTest.php new file mode 100644 index 0000000..6f3d61d --- /dev/null +++ b/tests/HigherOrderTapProxyTest.php @@ -0,0 +1,21 @@ +called = true; + } + }; + + $proxy = new HigherOrderTapProxy($target); + + $proxy->foo(); + + expect($target->called)->toBeTrue(); +});