Skip to content
This repository was archived by the owner on Oct 9, 2024. It is now read-only.

Commit b3e345d

Browse files
committed
chore: Update static files before release.
1 parent f1af8c6 commit b3e345d

File tree

3 files changed

+25
-17
lines changed

3 files changed

+25
-17
lines changed

.github/settings.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ repository:
2424
allow_rebase_merge: false
2525
allow_squash_merge: true
2626
default_branch: master
27-
description: "Memoize a closure or a callable."
28-
topics: memoize,php
27+
description: "Memoize a closure."
28+
topics: memoize, memoization, memoizer, cache, educational
2929
has_downloads: true
3030
has_issues: true
3131
has_pages: false

README.md

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,20 +46,29 @@ namespace App;
4646

4747
include 'vendor/autoload.php';
4848

49+
use Closure;
4950
use loophp\memoize\Memoizer;
5051

51-
$callback = function ($a = 5, $b = 10) {
52-
sleep(5);
53-
54-
return \sprintf('Param 1: %s Param 2: %s%s', $a, $b, \PHP_EOL);
52+
$fibonacci = static function (int $number) use (&$fibonacci): int {
53+
return (1 >= $number) ?
54+
$number :
55+
$fibonacci($number - 1) + $fibonacci($number - 2);
5556
};
5657

57-
$memoizer = Memoizer::fromClosure($callback);
58+
$fibonacci = Memoizer::fromClosure($fibonacci);
59+
60+
function bench(Closure $closure, ...$arguments): array
61+
{
62+
$start = microtime(true);
63+
64+
return [
65+
$closure(...$arguments),
66+
microtime(true) - $start,
67+
];
68+
}
5869

59-
echo $memoizer('A', 'B') . "\n";
60-
echo $memoizer('C', 'D') . "\n";
61-
echo $memoizer('A', 'B') . "\n";
62-
echo $memoizer('C', 'D') . "\n";
70+
var_dump(sprintf('[return: %s] [duration: %s]', ...bench($fibonacci, 50)));
71+
var_dump(sprintf('[return: %s] [duration: %s]', ...bench($fibonacci, 50)));
6372
```
6473

6574
## Code style, code quality, tests and benchmarks

composer.json

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
{
22
"name": "loophp/memoize",
3-
"description": "Memoize a callable.",
3+
"description": "Memoize a closure.",
44
"keywords": [
55
"memoize",
66
"memoization",
77
"memoizer",
8-
"cache"
8+
"cache",
9+
"educational"
910
],
1011
"homepage": "https://github.com/loophp/memoize",
1112
"license": "MIT",
@@ -18,12 +19,10 @@
1819
}
1920
],
2021
"require": {
21-
"php": ">= 7.4",
22-
"ext-json": "*"
22+
"php": ">= 7.4"
2323
},
2424
"require-dev": {
25-
"amphp/amp": "^2.5",
26-
"drupol/php-conventions": "^2.0.2",
25+
"drupol/php-conventions": "^2.0.3",
2726
"friends-of-phpspec/phpspec-code-coverage": "^5",
2827
"infection/infection": "^0.20",
2928
"infection/phpspec-adapter": "^0.1.1",

0 commit comments

Comments
 (0)