From 9d6c891ae6761031caa6fec1b02a286b7f808bd1 Mon Sep 17 00:00:00 2001 From: Cristian Tabacitu Date: Thu, 25 Nov 2021 00:08:56 +0200 Subject: [PATCH] use fluent string helpers --- src/blade_directives.php | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/blade_directives.php b/src/blade_directives.php index 666e84b..f6d7159 100644 --- a/src/blade_directives.php +++ b/src/blade_directives.php @@ -12,14 +12,15 @@ Blade::directive('loadOnce', function ($parameter) { // determine if it's a CSS or JS file - $filePath = $parameter; - $filePath = trim($filePath, "'"); - $filePath = trim($filePath, '"'); - $filePath = trim($filePath, '`'); - $filePath = Str::before($filePath, '?'); - $filePath = Str::before($filePath, '#'); + $cleanParameter = Str::of($parameter)->trim("'")->trim('"')->trim('`'); + $filePath = Str::of($cleanParameter)->before('?')->before('#'); $extension = substr($filePath, -3); + // mey be useful to get the second parameter + // if (Str::contains($parameter, ',')) { + // $secondParameter = Str::of($parameter)->after(',')->trim(' '); + // } + switch ($extension) { case 'css': return ""; @@ -31,11 +32,8 @@ default: // it's a block start - $parameter = trim($parameter, "'"); - $parameter = trim($parameter, '"'); - $parameter = trim($parameter, '`'); - return ""; + return ""; break; } });