Skip to content

Commit

Permalink
reduce complexity
Browse files Browse the repository at this point in the history
  • Loading branch information
rikmeijer committed Nov 7, 2023
1 parent e6e15f7 commit 0be9298
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/UI/Template.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ static function extract(callable $try) : mixed {
return $reflection->getStaticVariables()['value'];
}

static function negotiateType(callable $directory) {
static function negotiateType(callable $blocks) {
return fn(callable $templateExists) => fn(callable $found, callable $missingType) => $templateExists(
[Functional::class, 'populated'],
Functional::first(
fn(string $typePath, string $acceptedType) => $found($acceptedType, self::render(file_get_contents($typePath))(self::open($directory('.php')))),
fn(string $typePath, string $acceptedType) => $found($acceptedType, self::render(file_get_contents($typePath))($blocks)),
),
$missingType
);
Expand All @@ -56,7 +56,7 @@ static function negotiateResource(callable $resourceExists, callable $methodNego
static function negotiate(callable $directory, string $method) : callable {
return self::negotiateResource(
Functional::curry(self::try($directory('')))('is_dir')(fn(string $path) => glob($path . DIRECTORY_SEPARATOR . $method . '.*')),
self::negotiateMethod(self::negotiateType($directory), Functional::map(fn(float $v, string $k) => $directory(DIRECTORY_SEPARATOR . $method . '.' . self::typeToExtension($k))))
self::negotiateMethod(self::negotiateType(self::open($directory('.php'))), Functional::map(fn(float $v, string $k) => $directory(DIRECTORY_SEPARATOR . $method . '.' . self::typeToExtension($k))))
);
}

Expand Down

0 comments on commit 0be9298

Please sign in to comment.