first commit

This commit is contained in:
2025-04-27 04:02:46 +02:00
commit 05e8cca347
47 changed files with 2723 additions and 0 deletions

View File

@@ -0,0 +1,85 @@
<?php
require __DIR__ . '/../vendor/autoload.php';
use Anikeen\Id\AnikeenId;
use Illuminate\Support\Arr;
$markdown = collect(class_uses(AnikeenId::class))
->map(function ($trait) {
$title = str_replace('Trait', '', Arr::last(explode('\\', $trait)));
$methods = [];
$reflection = new ReflectionClass($trait);
collect($reflection->getMethods())
->reject(function (ReflectionMethod $method) {
return $method->isAbstract();
})
->reject(function (ReflectionMethod $method) {
return $method->isPrivate() || $method->isProtected();
})
->reject(function (ReflectionMethod $method) {
return $method->isConstructor();
})
->each(function (ReflectionMethod $method) use (&$methods, $title, $trait) {
$declaration = collect($method->getModifiers())->map(function (int $modifier) {
return $modifier == ReflectionMethod::IS_PUBLIC ? 'public ' : '';
})->join(' ');
$declaration .= 'function ';
$declaration .= $method->getName();
$declaration .= '(';
$declaration .= collect($method->getParameters())->map(function (ReflectionParameter $parameter) {
$parameterString = Arr::last(explode('\\', $parameter->getType()->getName()));
$parameterString .= ' ';
$parameterString .= '$';
$parameterString .= $parameter->getName();
if ($parameter->isDefaultValueAvailable()) {
$parameterString .= ' = ';
$parameterString .= str_replace(PHP_EOL, '', var_export($parameter->getDefaultValue(), true));
}
return $parameterString;
})->join(', ');
$declaration .= ')';
$methods[] = $declaration;
});
return [$title, $methods];
})
->map(function ($args) {
list($title, $methods) = $args;
$markdown = '### ' . $title;
$markdown .= PHP_EOL . PHP_EOL;
$markdown .= '```php';
$markdown .= PHP_EOL;
$markdown .= collect($methods)->each(function ($method) {
return $method;
})->implode(PHP_EOL);
$markdown .= PHP_EOL;
$markdown .= '```';
return $markdown;
})->join(PHP_EOL . PHP_EOL);
$markdown = str_replace("array (\n)", '[]', $markdown);
$content = file_get_contents(__DIR__ . '/../README.stub');
$content = str_replace('<!-- GENERATED-DOCS -->', $markdown, $content);
file_put_contents(__DIR__ . '/../README.md', $content);