diff options
| author | Sam Light <sam@lightscale.co.uk> | 2025-03-31 23:20:55 +0100 | 
|---|---|---|
| committer | Sam Light <samlight1994@gmail.com> | 2025-03-31 23:20:55 +0100 | 
| commit | 35e124960f3103d0cebc5b843054930c730998ab (patch) | |
| tree | 1aec8df0846870958ba836c5e50ceed36b0a2885 | |
| parent | d700b3b5772022902948430d076fc3c0a00f20ef (diff) | |
Changes to the File classes
| -rw-r--r-- | src/File.php | 19 | ||||
| -rw-r--r-- | src/ScriptFile.php | 7 | ||||
| -rw-r--r-- | src/StyleFile.php | 7 | 
3 files changed, 14 insertions, 19 deletions
| 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}\" />";      }  } | 
