Skip to content

Commit

Permalink
Use callable method parameter
Browse files Browse the repository at this point in the history
Gets better IDE support and doesn't report the methods as unused
  • Loading branch information
caendesilva committed Jun 26, 2024
1 parent 877aa04 commit 5fc1c1c
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/framework/src/Support/Includes.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public static function get(string $filename, ?string $default = null): ?string
*/
public static function html(string $filename, ?string $default = null): ?HtmlString
{
return static::getInclude('renderHtml', '.html', $default, $filename);
return static::getInclude([static::class, 'renderHtml'], '.html', $default, $filename);
}

/**
Expand All @@ -78,7 +78,7 @@ public static function html(string $filename, ?string $default = null): ?HtmlStr
*/
public static function markdown(string $filename, ?string $default = null): ?HtmlString
{
return static::getInclude('renderMarkdown', '.md', $default, $filename);
return static::getInclude([static::class, 'renderMarkdown'], '.md', $default, $filename);
}

/**
Expand All @@ -90,7 +90,7 @@ public static function markdown(string $filename, ?string $default = null): ?Htm
*/
public static function blade(string $filename, ?string $default = null): ?HtmlString
{
return static::getInclude('renderBlade', '.blade.php', $default, $filename);
return static::getInclude([static::class, 'renderBlade'], '.blade.php', $default, $filename);
}

protected static function normalizePath(string $filename, string $extension): string
Expand Down Expand Up @@ -122,7 +122,7 @@ protected static function getFileContents(string $path): ?string
return Filesystem::get($path);
}

protected static function getInclude(string $method, string $extension, ?string $default, string $filename): ?HtmlString
protected static function getInclude(callable $method, string $extension, ?string $default, string $filename): ?HtmlString
{
$path = static::normalizePath($filename, $extension);
$contents = static::getFileContents($path);
Expand All @@ -131,6 +131,6 @@ protected static function getInclude(string $method, string $extension, ?string
return null;
}

return static::$method($contents ?? $default);
return $method($contents ?? $default);
}
}

0 comments on commit 5fc1c1c

Please sign in to comment.