From 35e124960f3103d0cebc5b843054930c730998ab Mon Sep 17 00:00:00 2001
From: Sam Light <sam@lightscale.co.uk>
Date: Mon, 31 Mar 2025 23:20:55 +0100
Subject: Changes to the File classes

---
 src/File.php       | 19 ++++++++++++-------
 src/ScriptFile.php |  7 +------
 src/StyleFile.php  |  7 +------
 3 files changed, 14 insertions(+), 19 deletions(-)

(limited to 'src')

diff --git a/src/File.php b/src/File.php
index b2c52fc..85738f6 100644
--- a/src/File.php
+++ b/src/File.php
@@ -6,23 +6,28 @@ use Illuminate\Contracts\Support\Htmlable;
 
 abstract class File implements Htmlable
 {
-    private string $path;
+    private string $url;
 
-    protected function setPath(string $path): void
+    public function __construct(string $path)
     {
-        $this->path = $path;
+        $this->setUrl($path);
     }
 
-    public function getPath(): string
+    protected function setUrl(string $url): void
     {
-        return $this->path;
+        $this->url = $url;
+    }
+
+    public function getUrl(): string
+    {
+        return $this->url;
     }
 
     public function hash(): string
     {
         $class = static::class;
-        return md5("{$class}|{$this->path}");
+        return md5("{$class}|{$this->url}");
     }
 
-    abstract public function toHtml(): string
+    abstract public function toHtml(): string;
 }
diff --git a/src/ScriptFile.php b/src/ScriptFile.php
index f8f11cd..b1c4449 100644
--- a/src/ScriptFile.php
+++ b/src/ScriptFile.php
@@ -4,14 +4,9 @@ namespace Lightscale\LaralightAssets;
 
 class ScriptFile extends File
 {
-    public function __construct(string $path)
-    {
-        $this->setPath($path);
-    }
-
     public function toHtml(): string
     {
-        $path = $this->getPath();
+        $path = $this->getUrl();
         return "<script src=\"{$path}\"></script>";
     }
 }
diff --git a/src/StyleFile.php b/src/StyleFile.php
index ea3e425..0007215 100644
--- a/src/StyleFile.php
+++ b/src/StyleFile.php
@@ -4,14 +4,9 @@ namespace Lightscale\LaralightAssets;
 
 class StyleFile extends File
 {
-    public function __construct(string $path)
-    {
-        $this->setPath($path);
-    }
-
     public function toHtml(): string
     {
-        $path = $this->getPath();
+        $path = $this->getUrl();
         return "<link type=\"text/css\" rel=\"stylesheet\" href=\"{$path}\" />";
     }
 }
-- 
cgit v1.2.3