summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Light <sam@lightscale.co.uk>2025-03-31 00:49:13 +0100
committerSam Light <samlight1994@gmail.com>2025-03-31 00:49:13 +0100
commit28e2f2c50c902d6ea09b2d6941c9e71ea07b23eb (patch)
tree92a7cf5d38f01738ae88e161147a5770f673f105
parentd80d1d27c3a5dcea6f341e0bc29653acfde6b5ea (diff)
Created files for files to load
-rw-r--r--src/File.php22
-rw-r--r--src/ScriptFile.php17
-rw-r--r--src/StyleFile.php17
3 files changed, 55 insertions, 1 deletions
diff --git a/src/File.php b/src/File.php
index 3e64938..b2c52fc 100644
--- a/src/File.php
+++ b/src/File.php
@@ -2,7 +2,27 @@
namespace Lightscale\LaralightAssets;
-class File
+use Illuminate\Contracts\Support\Htmlable;
+
+abstract class File implements Htmlable
{
+ private string $path;
+
+ protected function setPath(string $path): void
+ {
+ $this->path = $path;
+ }
+
+ public function getPath(): string
+ {
+ return $this->path;
+ }
+
+ public function hash(): string
+ {
+ $class = static::class;
+ return md5("{$class}|{$this->path}");
+ }
+ abstract public function toHtml(): string
}
diff --git a/src/ScriptFile.php b/src/ScriptFile.php
new file mode 100644
index 0000000..f8f11cd
--- /dev/null
+++ b/src/ScriptFile.php
@@ -0,0 +1,17 @@
+<?php
+
+namespace Lightscale\LaralightAssets;
+
+class ScriptFile extends File
+{
+ public function __construct(string $path)
+ {
+ $this->setPath($path);
+ }
+
+ public function toHtml(): string
+ {
+ $path = $this->getPath();
+ return "<script src=\"{$path}\"></script>";
+ }
+}
diff --git a/src/StyleFile.php b/src/StyleFile.php
new file mode 100644
index 0000000..ea3e425
--- /dev/null
+++ b/src/StyleFile.php
@@ -0,0 +1,17 @@
+<?php
+
+namespace Lightscale\LaralightAssets;
+
+class StyleFile extends File
+{
+ public function __construct(string $path)
+ {
+ $this->setPath($path);
+ }
+
+ public function toHtml(): string
+ {
+ $path = $this->getPath();
+ return "<link type=\"text/css\" rel=\"stylesheet\" href=\"{$path}\" />";
+ }
+}