From c15c8271065010d79b1a57a05cc767f908a64472 Mon Sep 17 00:00:00 2001
From: Caen De Silva <caen@desilva.se>
Date: Sat, 29 Oct 2022 14:23:51 +0200
Subject: [PATCH 01/29] Create FeaturedImageFactory.php

---
 .../src/Framework/Factories/FeaturedImageFactory.php   | 10 ++++++++++
 1 file changed, 10 insertions(+)
 create mode 100644 packages/framework/src/Framework/Factories/FeaturedImageFactory.php

diff --git a/packages/framework/src/Framework/Factories/FeaturedImageFactory.php b/packages/framework/src/Framework/Factories/FeaturedImageFactory.php
new file mode 100644
index 00000000000..ad096219b49
--- /dev/null
+++ b/packages/framework/src/Framework/Factories/FeaturedImageFactory.php
@@ -0,0 +1,10 @@
+<?php
+
+declare(strict_types=1);
+
+namespace Hyde\Framework\Factories;
+
+class FeaturedImageFactory
+{
+    //
+}

From aeafe3ed191a60b8977f4048ec37452cb2dff4d8 Mon Sep 17 00:00:00 2001
From: Caen De Silva <caen@desilva.se>
Date: Sat, 29 Oct 2022 14:24:07 +0200
Subject: [PATCH 02/29] Extends PageDataFactory, implements FeaturedImageSchema

---
 .../src/Framework/Factories/FeaturedImageFactory.php          | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/packages/framework/src/Framework/Factories/FeaturedImageFactory.php b/packages/framework/src/Framework/Factories/FeaturedImageFactory.php
index ad096219b49..87fa852e329 100644
--- a/packages/framework/src/Framework/Factories/FeaturedImageFactory.php
+++ b/packages/framework/src/Framework/Factories/FeaturedImageFactory.php
@@ -4,7 +4,9 @@
 
 namespace Hyde\Framework\Factories;
 
-class FeaturedImageFactory
+use Hyde\Markdown\Contracts\FrontMatter\SubSchemas\FeaturedImageSchema;
+
+class FeaturedImageFactory extends Concerns\PageDataFactory implements FeaturedImageSchema
 {
     //
 }

From 93aa4588f56f2f2a8429b6e0887ef0f97339d036 Mon Sep 17 00:00:00 2001
From: Caen De Silva <caen@desilva.se>
Date: Sat, 29 Oct 2022 14:25:19 +0200
Subject: [PATCH 03/29] Add schema constant

---
 .../framework/src/Framework/Factories/FeaturedImageFactory.php  | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/packages/framework/src/Framework/Factories/FeaturedImageFactory.php b/packages/framework/src/Framework/Factories/FeaturedImageFactory.php
index 87fa852e329..3504f5b66d6 100644
--- a/packages/framework/src/Framework/Factories/FeaturedImageFactory.php
+++ b/packages/framework/src/Framework/Factories/FeaturedImageFactory.php
@@ -8,5 +8,5 @@
 
 class FeaturedImageFactory extends Concerns\PageDataFactory implements FeaturedImageSchema
 {
-    //
+    public const SCHEMA = FeaturedImageSchema::FEATURED_IMAGE_SCHEMA;
 }

From f13014186c78168a97ba01cb53fdd2805aa1d699 Mon Sep 17 00:00:00 2001
From: Caen De Silva <caen@desilva.se>
Date: Sat, 29 Oct 2022 14:28:33 +0200
Subject: [PATCH 04/29] Add required method stub

---
 .../src/Framework/Factories/FeaturedImageFactory.php         | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/packages/framework/src/Framework/Factories/FeaturedImageFactory.php b/packages/framework/src/Framework/Factories/FeaturedImageFactory.php
index 3504f5b66d6..8f3ab986de2 100644
--- a/packages/framework/src/Framework/Factories/FeaturedImageFactory.php
+++ b/packages/framework/src/Framework/Factories/FeaturedImageFactory.php
@@ -9,4 +9,9 @@
 class FeaturedImageFactory extends Concerns\PageDataFactory implements FeaturedImageSchema
 {
     public const SCHEMA = FeaturedImageSchema::FEATURED_IMAGE_SCHEMA;
+
+    public function toArray(): array
+    {
+        // TODO: Implement toArray() method.
+    }
 }

From 3b651f76cc3b4042cd22142228853f122a08a166 Mon Sep 17 00:00:00 2001
From: Caen De Silva <caen@desilva.se>
Date: Sat, 29 Oct 2022 14:29:39 +0200
Subject: [PATCH 05/29] Add class properties

---
 .../src/Framework/Factories/FeaturedImageFactory.php      | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/packages/framework/src/Framework/Factories/FeaturedImageFactory.php b/packages/framework/src/Framework/Factories/FeaturedImageFactory.php
index 8f3ab986de2..159f41aa2dc 100644
--- a/packages/framework/src/Framework/Factories/FeaturedImageFactory.php
+++ b/packages/framework/src/Framework/Factories/FeaturedImageFactory.php
@@ -10,6 +10,14 @@ class FeaturedImageFactory extends Concerns\PageDataFactory implements FeaturedI
 {
     public const SCHEMA = FeaturedImageSchema::FEATURED_IMAGE_SCHEMA;
 
+    protected readonly ?string $altText;
+    protected readonly ?string $titleText;
+    protected readonly ?string $authorName;
+    protected readonly ?string $authorUrl;
+    protected readonly ?string $copyrightText;
+    protected readonly ?string $licenseName;
+    protected readonly ?string $licenseUrl;
+
     public function toArray(): array
     {
         // TODO: Implement toArray() method.

From 77a463d6bdbf99c4b5988571e56bb321543b7896 Mon Sep 17 00:00:00 2001
From: Caen De Silva <caen@desilva.se>
Date: Sat, 29 Oct 2022 14:30:37 +0200
Subject: [PATCH 06/29] Implement toArray() method.

---
 .../src/Framework/Factories/FeaturedImageFactory.php   | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/packages/framework/src/Framework/Factories/FeaturedImageFactory.php b/packages/framework/src/Framework/Factories/FeaturedImageFactory.php
index 159f41aa2dc..935124b2f18 100644
--- a/packages/framework/src/Framework/Factories/FeaturedImageFactory.php
+++ b/packages/framework/src/Framework/Factories/FeaturedImageFactory.php
@@ -20,6 +20,14 @@ class FeaturedImageFactory extends Concerns\PageDataFactory implements FeaturedI
 
     public function toArray(): array
     {
-        // TODO: Implement toArray() method.
+        return [
+            'altText' => $this->altText,
+            'titleText' => $this->titleText,
+            'authorName' => $this->authorName,
+            'authorUrl' => $this->authorUrl,
+            'copyrightText' => $this->copyrightText,
+            'licenseName' => $this->licenseName,
+            'licenseUrl' => $this->licenseUrl,
+        ];
     }
 }

From b164dafb4e69cd2dd00144754b0119d7495dd3f4 Mon Sep 17 00:00:00 2001
From: Caen De Silva <caen@desilva.se>
Date: Sat, 29 Oct 2022 14:31:53 +0200
Subject: [PATCH 07/29] Add constructor

---
 .../src/Framework/Factories/FeaturedImageFactory.php  | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/packages/framework/src/Framework/Factories/FeaturedImageFactory.php b/packages/framework/src/Framework/Factories/FeaturedImageFactory.php
index 935124b2f18..d0f561157a2 100644
--- a/packages/framework/src/Framework/Factories/FeaturedImageFactory.php
+++ b/packages/framework/src/Framework/Factories/FeaturedImageFactory.php
@@ -18,6 +18,17 @@ class FeaturedImageFactory extends Concerns\PageDataFactory implements FeaturedI
     protected readonly ?string $licenseName;
     protected readonly ?string $licenseUrl;
 
+    public function __construct()
+    {
+        $this->altText = $this->makeAltText();
+        $this->titleText = $this->makeTitleText();
+        $this->authorName = $this->makeAuthorName();
+        $this->authorUrl = $this->makeAuthorUrl();
+        $this->copyrightText = $this->makeCopyrightText();
+        $this->licenseName = $this->makeLicenseName();
+        $this->licenseUrl = $this->makeLicenseUrl();
+    }
+
     public function toArray(): array
     {
         return [

From 33afc45a32f5399f01fcba0ef2746cc5eb60755c Mon Sep 17 00:00:00 2001
From: Caen De Silva <caen@desilva.se>
Date: Sat, 29 Oct 2022 14:32:39 +0200
Subject: [PATCH 08/29] Add method stubs

---
 .../Factories/FeaturedImageFactory.php        | 35 +++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/packages/framework/src/Framework/Factories/FeaturedImageFactory.php b/packages/framework/src/Framework/Factories/FeaturedImageFactory.php
index d0f561157a2..994fd82fd7a 100644
--- a/packages/framework/src/Framework/Factories/FeaturedImageFactory.php
+++ b/packages/framework/src/Framework/Factories/FeaturedImageFactory.php
@@ -41,4 +41,39 @@ public function toArray(): array
             'licenseUrl' => $this->licenseUrl,
         ];
     }
+
+    protected function makeAltText(): ?string
+    {
+        return null;
+    }
+
+    protected function makeTitleText(): ?string
+    {
+        return null;
+    }
+
+    protected function makeAuthorName(): ?string
+    {
+        return null;
+    }
+
+    protected function makeAuthorUrl(): ?string
+    {
+        return null;
+    }
+
+    protected function makeCopyrightText(): ?string
+    {
+        return null;
+    }
+
+    protected function makeLicenseName(): ?string
+    {
+        return null;
+    }
+
+    protected function makeLicenseUrl(): ?string
+    {
+        return null;
+    }
 }

From d2a58563c5b5a7db81e12599f71a090fdd2efc38 Mon Sep 17 00:00:00 2001
From: Caen De Silva <caen@desilva.se>
Date: Sat, 29 Oct 2022 14:36:08 +0200
Subject: [PATCH 09/29] Create FeaturedImageFactoryTest.php

---
 .../tests/Feature/FeaturedImageFactoryTest.php   | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
 create mode 100644 packages/framework/tests/Feature/FeaturedImageFactoryTest.php

diff --git a/packages/framework/tests/Feature/FeaturedImageFactoryTest.php b/packages/framework/tests/Feature/FeaturedImageFactoryTest.php
new file mode 100644
index 00000000000..35161367f84
--- /dev/null
+++ b/packages/framework/tests/Feature/FeaturedImageFactoryTest.php
@@ -0,0 +1,16 @@
+<?php
+
+declare(strict_types=1);
+
+namespace Hyde\Framework\Testing\Feature;
+
+use Hyde\Framework\Factories\FeaturedImageFactory;
+use Hyde\Testing\TestCase;
+
+/**
+ * @covers \Hyde\Framework\Factories\FeaturedImageFactory
+ */
+class FeaturedImageFactoryTest extends TestCase
+{
+    //
+}

From e2ad4653a16dcb5b3d9833418904e195de3c12b0 Mon Sep 17 00:00:00 2001
From: Caen De Silva <caen@desilva.se>
Date: Sat, 29 Oct 2022 14:40:26 +0200
Subject: [PATCH 10/29] Factory needs to know front matter

---
 .../src/Framework/Factories/FeaturedImageFactory.php      | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/packages/framework/src/Framework/Factories/FeaturedImageFactory.php b/packages/framework/src/Framework/Factories/FeaturedImageFactory.php
index 994fd82fd7a..bee2a0cafd7 100644
--- a/packages/framework/src/Framework/Factories/FeaturedImageFactory.php
+++ b/packages/framework/src/Framework/Factories/FeaturedImageFactory.php
@@ -4,10 +4,14 @@
 
 namespace Hyde\Framework\Factories;
 
+use Hyde\Framework\Concerns\InteractsWithFrontMatter;
 use Hyde\Markdown\Contracts\FrontMatter\SubSchemas\FeaturedImageSchema;
+use Hyde\Markdown\Models\FrontMatter;
 
 class FeaturedImageFactory extends Concerns\PageDataFactory implements FeaturedImageSchema
 {
+    use InteractsWithFrontMatter;
+
     public const SCHEMA = FeaturedImageSchema::FEATURED_IMAGE_SCHEMA;
 
     protected readonly ?string $altText;
@@ -18,7 +22,9 @@ class FeaturedImageFactory extends Concerns\PageDataFactory implements FeaturedI
     protected readonly ?string $licenseName;
     protected readonly ?string $licenseUrl;
 
-    public function __construct()
+    public function __construct(
+        private readonly FrontMatter $matter,
+    )
     {
         $this->altText = $this->makeAltText();
         $this->titleText = $this->makeTitleText();

From 1efd4693a9a462b939ee2027cc0c2d82b3b0fb17 Mon Sep 17 00:00:00 2001
From: Caen De Silva <caen@desilva.se>
Date: Sat, 29 Oct 2022 14:48:12 +0200
Subject: [PATCH 11/29] Implement the factory

---
 .../Factories/FeaturedImageFactory.php        | 14 ++++-----
 .../Feature/FeaturedImageFactoryTest.php      | 30 ++++++++++++++++++-
 2 files changed, 36 insertions(+), 8 deletions(-)

diff --git a/packages/framework/src/Framework/Factories/FeaturedImageFactory.php b/packages/framework/src/Framework/Factories/FeaturedImageFactory.php
index bee2a0cafd7..4e8392c0999 100644
--- a/packages/framework/src/Framework/Factories/FeaturedImageFactory.php
+++ b/packages/framework/src/Framework/Factories/FeaturedImageFactory.php
@@ -50,36 +50,36 @@ public function toArray(): array
 
     protected function makeAltText(): ?string
     {
-        return null;
+        return $this->matter('description');
     }
 
     protected function makeTitleText(): ?string
     {
-        return null;
+        return $this->matter('title');
     }
 
     protected function makeAuthorName(): ?string
     {
-        return null;
+        return $this->matter('author');
     }
 
     protected function makeAuthorUrl(): ?string
     {
-        return null;
+        return $this->matter('attributionUrl');
     }
 
     protected function makeCopyrightText(): ?string
     {
-        return null;
+        return $this->matter('copyright');
     }
 
     protected function makeLicenseName(): ?string
     {
-        return null;
+        return $this->matter('license');
     }
 
     protected function makeLicenseUrl(): ?string
     {
-        return null;
+        return $this->matter('licenseUrl');
     }
 }
diff --git a/packages/framework/tests/Feature/FeaturedImageFactoryTest.php b/packages/framework/tests/Feature/FeaturedImageFactoryTest.php
index 35161367f84..0ddd9f859a4 100644
--- a/packages/framework/tests/Feature/FeaturedImageFactoryTest.php
+++ b/packages/framework/tests/Feature/FeaturedImageFactoryTest.php
@@ -5,6 +5,7 @@
 namespace Hyde\Framework\Testing\Feature;
 
 use Hyde\Framework\Factories\FeaturedImageFactory;
+use Hyde\Markdown\Models\FrontMatter;
 use Hyde\Testing\TestCase;
 
 /**
@@ -12,5 +13,32 @@
  */
 class FeaturedImageFactoryTest extends TestCase
 {
-    //
+    public function testWithDataFromSchema()
+    {
+        $array = [
+            'path' => 'path',
+            'url' => 'url',
+            'description' => 'description',
+            'title' => 'title',
+            'copyright' => 'copyright',
+            'license' => 'license',
+            'licenseUrl' => 'licenseUrl',
+            'author' => 'author',
+            'attributionUrl' => 'attributionUrl',
+        ];
+
+        $expected = [
+            'altText' => 'description',
+            'titleText' => 'title',
+            'authorName' => 'author',
+            'authorUrl' => 'attributionUrl',
+            'copyrightText' => 'copyright',
+            'licenseName' => 'license',
+            'licenseUrl' => 'licenseUrl',
+        ];
+
+        $factory = new FeaturedImageFactory(new FrontMatter($array));
+
+        $this->assertSame($expected, $factory->toArray());
+    }
 }

From b043824f28484ab99617a020b445ea55866cf411 Mon Sep 17 00:00:00 2001
From: Caen De Silva <caen@desilva.se>
Date: Sat, 29 Oct 2022 14:52:17 +0200
Subject: [PATCH 12/29] Sketch out make method

---
 .../Factories/FeaturedImageFactory.php        |  8 ++++++
 .../Feature/FeaturedImageFactoryTest.php      | 25 +++++++++++++++++++
 2 files changed, 33 insertions(+)

diff --git a/packages/framework/src/Framework/Factories/FeaturedImageFactory.php b/packages/framework/src/Framework/Factories/FeaturedImageFactory.php
index 4e8392c0999..f95b7dbdc57 100644
--- a/packages/framework/src/Framework/Factories/FeaturedImageFactory.php
+++ b/packages/framework/src/Framework/Factories/FeaturedImageFactory.php
@@ -5,6 +5,7 @@
 namespace Hyde\Framework\Factories;
 
 use Hyde\Framework\Concerns\InteractsWithFrontMatter;
+use Hyde\Framework\Features\Blogging\Models\FeaturedImage;
 use Hyde\Markdown\Contracts\FrontMatter\SubSchemas\FeaturedImageSchema;
 use Hyde\Markdown\Models\FrontMatter;
 
@@ -48,6 +49,13 @@ public function toArray(): array
         ];
     }
 
+    public static function make(FrontMatter $matter): FeaturedImage
+    {
+        $data = (new static($matter))->toArray();
+
+        // Todo: Return the proper image type
+    }
+
     protected function makeAltText(): ?string
     {
         return $this->matter('description');
diff --git a/packages/framework/tests/Feature/FeaturedImageFactoryTest.php b/packages/framework/tests/Feature/FeaturedImageFactoryTest.php
index 0ddd9f859a4..9c51402c06e 100644
--- a/packages/framework/tests/Feature/FeaturedImageFactoryTest.php
+++ b/packages/framework/tests/Feature/FeaturedImageFactoryTest.php
@@ -41,4 +41,29 @@ public function testWithDataFromSchema()
 
         $this->assertSame($expected, $factory->toArray());
     }
+
+    public function testMakeMethodCreatesLocalImageWhenPathIsSet()
+    {
+        
+    }
+
+    public function testMakeMethodCreatesRemoteImageWhenUrlIsSet()
+    {
+        
+    }
+
+    public function testMakeMethodCreatesRemoteImageWhenBothUrlAndPathIsSet()
+    {
+
+    }
+
+    public function testMakeMethodThrowsExceptionIfNoPathInformationIsSet()
+    {
+        
+    }
+
+    public function testMakeMethodCanCreateImageFromJustString()
+    {
+        
+    }
 }

From ca4d1dcc06e05d3d25e50b0b4435a8689e6d752c Mon Sep 17 00:00:00 2001
From: Caen De Silva <caen@desilva.se>
Date: Sat, 29 Oct 2022 14:57:26 +0200
Subject: [PATCH 13/29] Fix whoopsie: front matter keys must obviously be
 prefixed with image

---
 .../Factories/FeaturedImageFactory.php         | 14 +++++++-------
 .../tests/Feature/FeaturedImageFactoryTest.php | 18 +++++++++---------
 2 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/packages/framework/src/Framework/Factories/FeaturedImageFactory.php b/packages/framework/src/Framework/Factories/FeaturedImageFactory.php
index f95b7dbdc57..69a86d105a6 100644
--- a/packages/framework/src/Framework/Factories/FeaturedImageFactory.php
+++ b/packages/framework/src/Framework/Factories/FeaturedImageFactory.php
@@ -58,36 +58,36 @@ public static function make(FrontMatter $matter): FeaturedImage
 
     protected function makeAltText(): ?string
     {
-        return $this->matter('description');
+        return $this->matter('image.description');
     }
 
     protected function makeTitleText(): ?string
     {
-        return $this->matter('title');
+        return $this->matter('image.title');
     }
 
     protected function makeAuthorName(): ?string
     {
-        return $this->matter('author');
+        return $this->matter('image.author');
     }
 
     protected function makeAuthorUrl(): ?string
     {
-        return $this->matter('attributionUrl');
+        return $this->matter('image.attributionUrl');
     }
 
     protected function makeCopyrightText(): ?string
     {
-        return $this->matter('copyright');
+        return $this->matter('image.copyright');
     }
 
     protected function makeLicenseName(): ?string
     {
-        return $this->matter('license');
+        return $this->matter('image.license');
     }
 
     protected function makeLicenseUrl(): ?string
     {
-        return $this->matter('licenseUrl');
+        return $this->matter('image.licenseUrl');
     }
 }
diff --git a/packages/framework/tests/Feature/FeaturedImageFactoryTest.php b/packages/framework/tests/Feature/FeaturedImageFactoryTest.php
index 9c51402c06e..44bc6052709 100644
--- a/packages/framework/tests/Feature/FeaturedImageFactoryTest.php
+++ b/packages/framework/tests/Feature/FeaturedImageFactoryTest.php
@@ -16,15 +16,15 @@ class FeaturedImageFactoryTest extends TestCase
     public function testWithDataFromSchema()
     {
         $array = [
-            'path' => 'path',
-            'url' => 'url',
-            'description' => 'description',
-            'title' => 'title',
-            'copyright' => 'copyright',
-            'license' => 'license',
-            'licenseUrl' => 'licenseUrl',
-            'author' => 'author',
-            'attributionUrl' => 'attributionUrl',
+            'image.path' => 'path',
+            'image.url' => 'url',
+            'image.description' => 'description',
+            'image.title' => 'title',
+            'image.copyright' => 'copyright',
+            'image.license' => 'license',
+            'image.licenseUrl' => 'licenseUrl',
+            'image.author' => 'author',
+            'image.attributionUrl' => 'attributionUrl',
         ];
 
         $expected = [

From a196c0a838b729f5f771deee12d79232bc206020 Mon Sep 17 00:00:00 2001
From: Caen De Silva <caen@desilva.se>
Date: Sat, 29 Oct 2022 14:58:24 +0200
Subject: [PATCH 14/29] Add source property

---
 .../src/Framework/Factories/FeaturedImageFactory.php       | 7 +++++++
 .../framework/tests/Feature/FeaturedImageFactoryTest.php   | 1 +
 2 files changed, 8 insertions(+)

diff --git a/packages/framework/src/Framework/Factories/FeaturedImageFactory.php b/packages/framework/src/Framework/Factories/FeaturedImageFactory.php
index 69a86d105a6..13d0615a01c 100644
--- a/packages/framework/src/Framework/Factories/FeaturedImageFactory.php
+++ b/packages/framework/src/Framework/Factories/FeaturedImageFactory.php
@@ -15,6 +15,7 @@ class FeaturedImageFactory extends Concerns\PageDataFactory implements FeaturedI
 
     public const SCHEMA = FeaturedImageSchema::FEATURED_IMAGE_SCHEMA;
 
+    protected readonly string $source;
     protected readonly ?string $altText;
     protected readonly ?string $titleText;
     protected readonly ?string $authorName;
@@ -27,6 +28,7 @@ public function __construct(
         private readonly FrontMatter $matter,
     )
     {
+        $this->source = $this->makeSource();
         $this->altText = $this->makeAltText();
         $this->titleText = $this->makeTitleText();
         $this->authorName = $this->makeAuthorName();
@@ -56,6 +58,11 @@ public static function make(FrontMatter $matter): FeaturedImage
         // Todo: Return the proper image type
     }
 
+    protected function makeSource(): string
+    {
+        // 
+    }
+
     protected function makeAltText(): ?string
     {
         return $this->matter('image.description');
diff --git a/packages/framework/tests/Feature/FeaturedImageFactoryTest.php b/packages/framework/tests/Feature/FeaturedImageFactoryTest.php
index 44bc6052709..3d2908015f1 100644
--- a/packages/framework/tests/Feature/FeaturedImageFactoryTest.php
+++ b/packages/framework/tests/Feature/FeaturedImageFactoryTest.php
@@ -28,6 +28,7 @@ public function testWithDataFromSchema()
         ];
 
         $expected = [
+            'source' => 'url',
             'altText' => 'description',
             'titleText' => 'title',
             'authorName' => 'author',

From 968a34ed091d0b20575282191898f0ce41054728 Mon Sep 17 00:00:00 2001
From: Caen De Silva <caen@desilva.se>
Date: Sat, 29 Oct 2022 14:59:47 +0200
Subject: [PATCH 15/29] Dynamically set the source

---
 .../Framework/Factories/FeaturedImageFactory.php | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/packages/framework/src/Framework/Factories/FeaturedImageFactory.php b/packages/framework/src/Framework/Factories/FeaturedImageFactory.php
index 13d0615a01c..e7d313cd237 100644
--- a/packages/framework/src/Framework/Factories/FeaturedImageFactory.php
+++ b/packages/framework/src/Framework/Factories/FeaturedImageFactory.php
@@ -8,6 +8,7 @@
 use Hyde\Framework\Features\Blogging\Models\FeaturedImage;
 use Hyde\Markdown\Contracts\FrontMatter\SubSchemas\FeaturedImageSchema;
 use Hyde\Markdown\Models\FrontMatter;
+use function is_string;
 
 class FeaturedImageFactory extends Concerns\PageDataFactory implements FeaturedImageSchema
 {
@@ -60,7 +61,20 @@ public static function make(FrontMatter $matter): FeaturedImage
 
     protected function makeSource(): string
     {
-        // 
+        if (is_string($this->matter('image')))
+        {
+            return $this->matter('image');
+        }
+
+        if ($this->matter('image.url') !== null)
+        {
+            return $this->matter('image.url');
+        }
+
+        if ($this->matter('image.path') !== null)
+        {
+            return $this->matter('image.path');
+        }
     }
 
     protected function makeAltText(): ?string

From 799589b01136cecf925d3f6b9fc5eda3c54614f0 Mon Sep 17 00:00:00 2001
From: Caen De Silva <caen@desilva.se>
Date: Sat, 29 Oct 2022 14:59:56 +0200
Subject: [PATCH 16/29] Throw RuntimeException if no source is set

---
 .../src/Framework/Factories/FeaturedImageFactory.php          | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/packages/framework/src/Framework/Factories/FeaturedImageFactory.php b/packages/framework/src/Framework/Factories/FeaturedImageFactory.php
index e7d313cd237..b8bd7391a30 100644
--- a/packages/framework/src/Framework/Factories/FeaturedImageFactory.php
+++ b/packages/framework/src/Framework/Factories/FeaturedImageFactory.php
@@ -8,6 +8,7 @@
 use Hyde\Framework\Features\Blogging\Models\FeaturedImage;
 use Hyde\Markdown\Contracts\FrontMatter\SubSchemas\FeaturedImageSchema;
 use Hyde\Markdown\Models\FrontMatter;
+use RuntimeException;
 use function is_string;
 
 class FeaturedImageFactory extends Concerns\PageDataFactory implements FeaturedImageSchema
@@ -75,6 +76,9 @@ protected function makeSource(): string
         {
             return $this->matter('image.path');
         }
+
+        // Todo, we might want to add a note about which file caused the error
+        throw new RuntimeException('No featured image source was found');
     }
 
     protected function makeAltText(): ?string

From 8b73fa05638fc680a56a0aa045d81e65c3811625 Mon Sep 17 00:00:00 2001
From: Caen De Silva <caen@desilva.se>
Date: Sat, 29 Oct 2022 15:33:33 +0200
Subject: [PATCH 17/29] Return the proper image type

---
 .../src/Framework/Factories/FeaturedImageFactory.php     | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/packages/framework/src/Framework/Factories/FeaturedImageFactory.php b/packages/framework/src/Framework/Factories/FeaturedImageFactory.php
index b8bd7391a30..54d353b4695 100644
--- a/packages/framework/src/Framework/Factories/FeaturedImageFactory.php
+++ b/packages/framework/src/Framework/Factories/FeaturedImageFactory.php
@@ -6,10 +6,13 @@
 
 use Hyde\Framework\Concerns\InteractsWithFrontMatter;
 use Hyde\Framework\Features\Blogging\Models\FeaturedImage;
+use Hyde\Framework\Features\Blogging\Models\LocalFeaturedImage;
+use Hyde\Framework\Features\Blogging\Models\RemoteFeaturedImage;
 use Hyde\Markdown\Contracts\FrontMatter\SubSchemas\FeaturedImageSchema;
 use Hyde\Markdown\Models\FrontMatter;
 use RuntimeException;
 use function is_string;
+use function str_starts_with;
 
 class FeaturedImageFactory extends Concerns\PageDataFactory implements FeaturedImageSchema
 {
@@ -57,7 +60,11 @@ public static function make(FrontMatter $matter): FeaturedImage
     {
         $data = (new static($matter))->toArray();
 
-        // Todo: Return the proper image type
+        if (str_starts_with($data['source'], 'http')) {
+            return new RemoteFeaturedImage(...$data);
+        }
+
+        return new LocalFeaturedImage(...$data);
     }
 
     protected function makeSource(): string

From 299800637bfb96bebce877b8509294458058bca1 Mon Sep 17 00:00:00 2001
From: Caen De Silva <caen@desilva.se>
Date: Sat, 29 Oct 2022 15:34:11 +0200
Subject: [PATCH 18/29] Source needs to be added to array

---
 .../framework/src/Framework/Factories/FeaturedImageFactory.php   | 1 +
 1 file changed, 1 insertion(+)

diff --git a/packages/framework/src/Framework/Factories/FeaturedImageFactory.php b/packages/framework/src/Framework/Factories/FeaturedImageFactory.php
index 54d353b4695..e7211a0417e 100644
--- a/packages/framework/src/Framework/Factories/FeaturedImageFactory.php
+++ b/packages/framework/src/Framework/Factories/FeaturedImageFactory.php
@@ -46,6 +46,7 @@ public function __construct(
     public function toArray(): array
     {
         return [
+            'source' => $this->source,
             'altText' => $this->altText,
             'titleText' => $this->titleText,
             'authorName' => $this->authorName,

From b612fdd107f5a90d8aa2959c99e5012f07d51aae Mon Sep 17 00:00:00 2001
From: Caen De Silva <caen@desilva.se>
Date: Sat, 29 Oct 2022 15:35:39 +0200
Subject: [PATCH 19/29] Normalize the local source path

---
 .../Factories/FeaturedImageFactory.php         | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/packages/framework/src/Framework/Factories/FeaturedImageFactory.php b/packages/framework/src/Framework/Factories/FeaturedImageFactory.php
index e7211a0417e..5a40fd9a4b3 100644
--- a/packages/framework/src/Framework/Factories/FeaturedImageFactory.php
+++ b/packages/framework/src/Framework/Factories/FeaturedImageFactory.php
@@ -8,6 +8,7 @@
 use Hyde\Framework\Features\Blogging\Models\FeaturedImage;
 use Hyde\Framework\Features\Blogging\Models\LocalFeaturedImage;
 use Hyde\Framework\Features\Blogging\Models\RemoteFeaturedImage;
+use Hyde\Hyde;
 use Hyde\Markdown\Contracts\FrontMatter\SubSchemas\FeaturedImageSchema;
 use Hyde\Markdown\Models\FrontMatter;
 use RuntimeException;
@@ -82,7 +83,7 @@ protected function makeSource(): string
 
         if ($this->matter('image.path') !== null)
         {
-            return $this->matter('image.path');
+            return $this->normalizeLocalImagePath($this->matter('image.path'));
         }
 
         // Todo, we might want to add a note about which file caused the error
@@ -123,4 +124,19 @@ protected function makeLicenseUrl(): ?string
     {
         return $this->matter('image.licenseUrl');
     }
+
+    protected static function normalizeLocalImagePath(string $path): string
+    {
+        $path = Hyde::pathToRelative($path);
+
+        if (str_starts_with($path, '_media/')) {
+            return $path;
+        }
+
+        if (str_starts_with($path, 'media/')) {
+            return '_'.$path;
+        }
+
+        return '_media/'.$path;
+    }
 }

From 555455edb6887cbaff3bbaa43c7bc77451abcdc4 Mon Sep 17 00:00:00 2001
From: Caen De Silva <caen@desilva.se>
Date: Sat, 29 Oct 2022 15:35:55 +0200
Subject: [PATCH 20/29] Update FeaturedImageFactoryTest.php

---
 .../framework/tests/Feature/FeaturedImageFactoryTest.php | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/packages/framework/tests/Feature/FeaturedImageFactoryTest.php b/packages/framework/tests/Feature/FeaturedImageFactoryTest.php
index 3d2908015f1..c8a8a9a5d68 100644
--- a/packages/framework/tests/Feature/FeaturedImageFactoryTest.php
+++ b/packages/framework/tests/Feature/FeaturedImageFactoryTest.php
@@ -5,6 +5,7 @@
 namespace Hyde\Framework\Testing\Feature;
 
 use Hyde\Framework\Factories\FeaturedImageFactory;
+use Hyde\Framework\Features\Blogging\Models\LocalFeaturedImage;
 use Hyde\Markdown\Models\FrontMatter;
 use Hyde\Testing\TestCase;
 
@@ -45,7 +46,13 @@ public function testWithDataFromSchema()
 
     public function testMakeMethodCreatesLocalImageWhenPathIsSet()
     {
-        
+        $array = [
+            'image.path' => 'path',
+        ];
+
+        $factory = FeaturedImageFactory::make(new FrontMatter($array));
+
+        $this->assertInstanceOf(LocalFeaturedImage::class, $factory);
     }
 
     public function testMakeMethodCreatesRemoteImageWhenUrlIsSet()

From 907fa06d4b07d28d342b7ab8cdd603c21d50ee7b Mon Sep 17 00:00:00 2001
From: Caen De Silva <caen@desilva.se>
Date: Sat, 29 Oct 2022 15:36:26 +0200
Subject: [PATCH 21/29] Inline variables

---
 .../tests/Feature/FeaturedImageFactoryTest.php       | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/packages/framework/tests/Feature/FeaturedImageFactoryTest.php b/packages/framework/tests/Feature/FeaturedImageFactoryTest.php
index c8a8a9a5d68..5dc7f4ff484 100644
--- a/packages/framework/tests/Feature/FeaturedImageFactoryTest.php
+++ b/packages/framework/tests/Feature/FeaturedImageFactoryTest.php
@@ -46,13 +46,11 @@ public function testWithDataFromSchema()
 
     public function testMakeMethodCreatesLocalImageWhenPathIsSet()
     {
-        $array = [
-            'image.path' => 'path',
-        ];
-
-        $factory = FeaturedImageFactory::make(new FrontMatter($array));
-
-        $this->assertInstanceOf(LocalFeaturedImage::class, $factory);
+        $this->assertInstanceOf(LocalFeaturedImage::class,
+            FeaturedImageFactory::make(new FrontMatter([
+                'image.path' => 'path',
+            ])
+        ));
     }
 
     public function testMakeMethodCreatesRemoteImageWhenUrlIsSet()

From 015d22c2c096381b768f1f74537e0257f563ab28 Mon Sep 17 00:00:00 2001
From: Caen De Silva <caen@desilva.se>
Date: Sat, 29 Oct 2022 15:37:00 +0200
Subject: [PATCH 22/29] Revert "Inline variables"

This reverts commit 907fa06d4b07d28d342b7ab8cdd603c21d50ee7b.
---
 .../tests/Feature/FeaturedImageFactoryTest.php       | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/packages/framework/tests/Feature/FeaturedImageFactoryTest.php b/packages/framework/tests/Feature/FeaturedImageFactoryTest.php
index 5dc7f4ff484..c8a8a9a5d68 100644
--- a/packages/framework/tests/Feature/FeaturedImageFactoryTest.php
+++ b/packages/framework/tests/Feature/FeaturedImageFactoryTest.php
@@ -46,11 +46,13 @@ public function testWithDataFromSchema()
 
     public function testMakeMethodCreatesLocalImageWhenPathIsSet()
     {
-        $this->assertInstanceOf(LocalFeaturedImage::class,
-            FeaturedImageFactory::make(new FrontMatter([
-                'image.path' => 'path',
-            ])
-        ));
+        $array = [
+            'image.path' => 'path',
+        ];
+
+        $factory = FeaturedImageFactory::make(new FrontMatter($array));
+
+        $this->assertInstanceOf(LocalFeaturedImage::class, $factory);
     }
 
     public function testMakeMethodCreatesRemoteImageWhenUrlIsSet()

From b6925b79991e0498394399e56cb8f9fb411256ba Mon Sep 17 00:00:00 2001
From: Caen De Silva <caen@desilva.se>
Date: Sat, 29 Oct 2022 15:37:14 +0200
Subject: [PATCH 23/29] Inline only single variable

---
 .../framework/tests/Feature/FeaturedImageFactoryTest.php    | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/packages/framework/tests/Feature/FeaturedImageFactoryTest.php b/packages/framework/tests/Feature/FeaturedImageFactoryTest.php
index c8a8a9a5d68..4adc9e5517c 100644
--- a/packages/framework/tests/Feature/FeaturedImageFactoryTest.php
+++ b/packages/framework/tests/Feature/FeaturedImageFactoryTest.php
@@ -46,11 +46,9 @@ public function testWithDataFromSchema()
 
     public function testMakeMethodCreatesLocalImageWhenPathIsSet()
     {
-        $array = [
+        $factory = FeaturedImageFactory::make(new FrontMatter([
             'image.path' => 'path',
-        ];
-
-        $factory = FeaturedImageFactory::make(new FrontMatter($array));
+        ]));
 
         $this->assertInstanceOf(LocalFeaturedImage::class, $factory);
     }

From d5b6037e7aa16469d5d6dac01df3d000d0fce3b7 Mon Sep 17 00:00:00 2001
From: Caen De Silva <caen@desilva.se>
Date: Sat, 29 Oct 2022 15:41:16 +0200
Subject: [PATCH 24/29] Invert logic to check on normalized data

---
 .../src/Framework/Factories/FeaturedImageFactory.php        | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/packages/framework/src/Framework/Factories/FeaturedImageFactory.php b/packages/framework/src/Framework/Factories/FeaturedImageFactory.php
index 5a40fd9a4b3..5b5daa2328d 100644
--- a/packages/framework/src/Framework/Factories/FeaturedImageFactory.php
+++ b/packages/framework/src/Framework/Factories/FeaturedImageFactory.php
@@ -62,11 +62,11 @@ public static function make(FrontMatter $matter): FeaturedImage
     {
         $data = (new static($matter))->toArray();
 
-        if (str_starts_with($data['source'], 'http')) {
-            return new RemoteFeaturedImage(...$data);
+        if (str_starts_with($data['source'], '_media')) {
+            return new LocalFeaturedImage(...$data);
         }
 
-        return new LocalFeaturedImage(...$data);
+        return new RemoteFeaturedImage(...$data);
     }
 
     protected function makeSource(): string

From 0f08b6195ad68034c706aeb679bf0b3cebb19e42 Mon Sep 17 00:00:00 2001
From: Caen De Silva <caen@desilva.se>
Date: Sat, 29 Oct 2022 15:44:33 +0200
Subject: [PATCH 25/29] No longer validate if remote image starts with http

---
 .../Features/Blogging/Models/RemoteFeaturedImage.php      | 5 +----
 packages/framework/tests/Feature/FeaturedImageTest.php    | 8 +++-----
 2 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/packages/framework/src/Framework/Features/Blogging/Models/RemoteFeaturedImage.php b/packages/framework/src/Framework/Features/Blogging/Models/RemoteFeaturedImage.php
index 2c89c134503..bbbb549220f 100644
--- a/packages/framework/src/Framework/Features/Blogging/Models/RemoteFeaturedImage.php
+++ b/packages/framework/src/Framework/Features/Blogging/Models/RemoteFeaturedImage.php
@@ -17,10 +17,7 @@ class RemoteFeaturedImage extends FeaturedImage
 
     protected function setSource(string $source): void
     {
-        if (! str_starts_with($source, 'http')) {
-            // Throwing an exception here ensures we have a super predictable state.
-            throw new InvalidArgumentException('RemoteFeaturedImage source must be a valid URL');
-        }
+        // Here we can validate the source URL if we want.
 
         $this->source = $source;
     }
diff --git a/packages/framework/tests/Feature/FeaturedImageTest.php b/packages/framework/tests/Feature/FeaturedImageTest.php
index ce1ca523b38..f3b0e0b5f3b 100644
--- a/packages/framework/tests/Feature/FeaturedImageTest.php
+++ b/packages/framework/tests/Feature/FeaturedImageTest.php
@@ -174,12 +174,10 @@ public function testCanConstructRemoteFeaturedImageWithHttps()
         $this->assertEquals('https/foo', $image->getSource());
     }
 
-    public function testCannotConstructRemoteFeaturedImageWithInvalidSource()
+    public function testCanConstructRemoteFeaturedImageWithInvalidSource()
     {
-        $this->expectException(InvalidArgumentException::class);
-        $this->expectExceptionMessage('RemoteFeaturedImage source must be a valid URL');
-
-        new RemoteFeaturedImage('foo', ...$this->defaultArguments());
+        $image = new RemoteFeaturedImage('foo', ...$this->defaultArguments());
+        $this->assertEquals('foo', $image->getSource());
     }
 
     public function testFeaturedImageGetContentLengthWithRemoteSource()

From 4b843c6818a4a537c629629d1be946be73278a05 Mon Sep 17 00:00:00 2001
From: Caen De Silva <caen@desilva.se>
Date: Sat, 29 Oct 2022 15:45:49 +0200
Subject: [PATCH 26/29] Implement the test stubs

---
 .../Feature/FeaturedImageFactoryTest.php      | 23 ++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/packages/framework/tests/Feature/FeaturedImageFactoryTest.php b/packages/framework/tests/Feature/FeaturedImageFactoryTest.php
index 4adc9e5517c..d83c06f581b 100644
--- a/packages/framework/tests/Feature/FeaturedImageFactoryTest.php
+++ b/packages/framework/tests/Feature/FeaturedImageFactoryTest.php
@@ -6,8 +6,10 @@
 
 use Hyde\Framework\Factories\FeaturedImageFactory;
 use Hyde\Framework\Features\Blogging\Models\LocalFeaturedImage;
+use Hyde\Framework\Features\Blogging\Models\RemoteFeaturedImage;
 use Hyde\Markdown\Models\FrontMatter;
 use Hyde\Testing\TestCase;
+use RuntimeException;
 
 /**
  * @covers \Hyde\Framework\Factories\FeaturedImageFactory
@@ -55,21 +57,36 @@ public function testMakeMethodCreatesLocalImageWhenPathIsSet()
 
     public function testMakeMethodCreatesRemoteImageWhenUrlIsSet()
     {
-        
+        $factory = FeaturedImageFactory::make(new FrontMatter([
+            'image.url' => 'url',
+        ]));
+
+        $this->assertInstanceOf(RemoteFeaturedImage::class, $factory);
     }
 
     public function testMakeMethodCreatesRemoteImageWhenBothUrlAndPathIsSet()
     {
+        $factory = FeaturedImageFactory::make(new FrontMatter([
+            'image.url' => 'url',
+            'image.path' => 'path',
+        ]));
 
+        $this->assertInstanceOf(RemoteFeaturedImage::class, $factory);
     }
 
     public function testMakeMethodThrowsExceptionIfNoPathInformationIsSet()
     {
-        
+        $this->expectException(RuntimeException::class);
+
+        FeaturedImageFactory::make(new FrontMatter([]));
     }
 
     public function testMakeMethodCanCreateImageFromJustString()
     {
-        
+        $factory = FeaturedImageFactory::make(new FrontMatter([
+            'image' => 'foo',
+        ]));
+
+        $this->assertInstanceOf(RemoteFeaturedImage::class, $factory);
     }
 }

From 74585aed9aaf84a5fa7cccc5d1d8a3143e491e60 Mon Sep 17 00:00:00 2001
From: Caen De Silva <caen@desilva.se>
Date: Sat, 29 Oct 2022 15:46:54 +0200
Subject: [PATCH 27/29] Add content assertions

---
 packages/framework/tests/Feature/FeaturedImageFactoryTest.php | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/packages/framework/tests/Feature/FeaturedImageFactoryTest.php b/packages/framework/tests/Feature/FeaturedImageFactoryTest.php
index d83c06f581b..64d5c015637 100644
--- a/packages/framework/tests/Feature/FeaturedImageFactoryTest.php
+++ b/packages/framework/tests/Feature/FeaturedImageFactoryTest.php
@@ -53,6 +53,7 @@ public function testMakeMethodCreatesLocalImageWhenPathIsSet()
         ]));
 
         $this->assertInstanceOf(LocalFeaturedImage::class, $factory);
+        $this->assertSame('_media/path', $factory->getSource());
     }
 
     public function testMakeMethodCreatesRemoteImageWhenUrlIsSet()
@@ -62,6 +63,7 @@ public function testMakeMethodCreatesRemoteImageWhenUrlIsSet()
         ]));
 
         $this->assertInstanceOf(RemoteFeaturedImage::class, $factory);
+        $this->assertSame('url', $factory->getSource());
     }
 
     public function testMakeMethodCreatesRemoteImageWhenBothUrlAndPathIsSet()
@@ -72,6 +74,7 @@ public function testMakeMethodCreatesRemoteImageWhenBothUrlAndPathIsSet()
         ]));
 
         $this->assertInstanceOf(RemoteFeaturedImage::class, $factory);
+        $this->assertSame('url', $factory->getSource());
     }
 
     public function testMakeMethodThrowsExceptionIfNoPathInformationIsSet()
@@ -88,5 +91,6 @@ public function testMakeMethodCanCreateImageFromJustString()
         ]));
 
         $this->assertInstanceOf(RemoteFeaturedImage::class, $factory);
+        $this->assertSame('foo', $factory->getSource());
     }
 }

From b90be86138a0620934d4bc9d3962ae71e01a42d1 Mon Sep 17 00:00:00 2001
From: Caen De Silva <caen@desilva.se>
Date: Sat, 29 Oct 2022 15:47:14 +0200
Subject: [PATCH 28/29] Fix local variable name

---
 .../Feature/FeaturedImageFactoryTest.php      | 24 +++++++++----------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/packages/framework/tests/Feature/FeaturedImageFactoryTest.php b/packages/framework/tests/Feature/FeaturedImageFactoryTest.php
index 64d5c015637..ff89baa4cb4 100644
--- a/packages/framework/tests/Feature/FeaturedImageFactoryTest.php
+++ b/packages/framework/tests/Feature/FeaturedImageFactoryTest.php
@@ -48,33 +48,33 @@ public function testWithDataFromSchema()
 
     public function testMakeMethodCreatesLocalImageWhenPathIsSet()
     {
-        $factory = FeaturedImageFactory::make(new FrontMatter([
+        $image = FeaturedImageFactory::make(new FrontMatter([
             'image.path' => 'path',
         ]));
 
-        $this->assertInstanceOf(LocalFeaturedImage::class, $factory);
-        $this->assertSame('_media/path', $factory->getSource());
+        $this->assertInstanceOf(LocalFeaturedImage::class, $image);
+        $this->assertSame('_media/path', $image->getSource());
     }
 
     public function testMakeMethodCreatesRemoteImageWhenUrlIsSet()
     {
-        $factory = FeaturedImageFactory::make(new FrontMatter([
+        $image = FeaturedImageFactory::make(new FrontMatter([
             'image.url' => 'url',
         ]));
 
-        $this->assertInstanceOf(RemoteFeaturedImage::class, $factory);
-        $this->assertSame('url', $factory->getSource());
+        $this->assertInstanceOf(RemoteFeaturedImage::class, $image);
+        $this->assertSame('url', $image->getSource());
     }
 
     public function testMakeMethodCreatesRemoteImageWhenBothUrlAndPathIsSet()
     {
-        $factory = FeaturedImageFactory::make(new FrontMatter([
+        $image = FeaturedImageFactory::make(new FrontMatter([
             'image.url' => 'url',
             'image.path' => 'path',
         ]));
 
-        $this->assertInstanceOf(RemoteFeaturedImage::class, $factory);
-        $this->assertSame('url', $factory->getSource());
+        $this->assertInstanceOf(RemoteFeaturedImage::class, $image);
+        $this->assertSame('url', $image->getSource());
     }
 
     public function testMakeMethodThrowsExceptionIfNoPathInformationIsSet()
@@ -86,11 +86,11 @@ public function testMakeMethodThrowsExceptionIfNoPathInformationIsSet()
 
     public function testMakeMethodCanCreateImageFromJustString()
     {
-        $factory = FeaturedImageFactory::make(new FrontMatter([
+        $image = FeaturedImageFactory::make(new FrontMatter([
             'image' => 'foo',
         ]));
 
-        $this->assertInstanceOf(RemoteFeaturedImage::class, $factory);
-        $this->assertSame('foo', $factory->getSource());
+        $this->assertInstanceOf(RemoteFeaturedImage::class, $image);
+        $this->assertSame('foo', $image->getSource());
     }
 }

From c6af53efff24316630d6ed0a362ed2d3ceca6e99 Mon Sep 17 00:00:00 2001
From: StyleCI Bot <bot@styleci.io>
Date: Sat, 29 Oct 2022 13:47:24 +0000
Subject: [PATCH 29/29] Apply fixes from StyleCI

---
 .../Framework/Factories/FeaturedImageFactory.php   | 14 +++++---------
 .../Blogging/Models/RemoteFeaturedImage.php        |  1 -
 2 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/packages/framework/src/Framework/Factories/FeaturedImageFactory.php b/packages/framework/src/Framework/Factories/FeaturedImageFactory.php
index 5b5daa2328d..2735d076b46 100644
--- a/packages/framework/src/Framework/Factories/FeaturedImageFactory.php
+++ b/packages/framework/src/Framework/Factories/FeaturedImageFactory.php
@@ -11,8 +11,8 @@
 use Hyde\Hyde;
 use Hyde\Markdown\Contracts\FrontMatter\SubSchemas\FeaturedImageSchema;
 use Hyde\Markdown\Models\FrontMatter;
-use RuntimeException;
 use function is_string;
+use RuntimeException;
 use function str_starts_with;
 
 class FeaturedImageFactory extends Concerns\PageDataFactory implements FeaturedImageSchema
@@ -32,8 +32,7 @@ class FeaturedImageFactory extends Concerns\PageDataFactory implements FeaturedI
 
     public function __construct(
         private readonly FrontMatter $matter,
-    )
-    {
+    ) {
         $this->source = $this->makeSource();
         $this->altText = $this->makeAltText();
         $this->titleText = $this->makeTitleText();
@@ -71,18 +70,15 @@ public static function make(FrontMatter $matter): FeaturedImage
 
     protected function makeSource(): string
     {
-        if (is_string($this->matter('image')))
-        {
+        if (is_string($this->matter('image'))) {
             return $this->matter('image');
         }
 
-        if ($this->matter('image.url') !== null)
-        {
+        if ($this->matter('image.url') !== null) {
             return $this->matter('image.url');
         }
 
-        if ($this->matter('image.path') !== null)
-        {
+        if ($this->matter('image.path') !== null) {
             return $this->normalizeLocalImagePath($this->matter('image.path'));
         }
 
diff --git a/packages/framework/src/Framework/Features/Blogging/Models/RemoteFeaturedImage.php b/packages/framework/src/Framework/Features/Blogging/Models/RemoteFeaturedImage.php
index bbbb549220f..0a42df2afd7 100644
--- a/packages/framework/src/Framework/Features/Blogging/Models/RemoteFeaturedImage.php
+++ b/packages/framework/src/Framework/Features/Blogging/Models/RemoteFeaturedImage.php
@@ -8,7 +8,6 @@
 use function array_key_exists;
 use function config;
 use Illuminate\Support\Facades\Http;
-use InvalidArgumentException;
 use function key;
 
 class RemoteFeaturedImage extends FeaturedImage
