From 911a0dabf1c311efc7c7a971045e0fd00f008ebe Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 20 May 2022 16:04:23 +0200 Subject: [PATCH] Create Action class to find Image content lengths --- .../FindsContentLengthForImageObject.php | 24 ++++++++++++++++++ src/Models/Image.php | 7 ++++++ .../FindsContentLengthForImageObjectTest.php | 25 +++++++++++++++++++ 3 files changed, 56 insertions(+) create mode 100644 src/Actions/FindsContentLengthForImageObject.php create mode 100644 tests/Feature/FindsContentLengthForImageObjectTest.php diff --git a/src/Actions/FindsContentLengthForImageObject.php b/src/Actions/FindsContentLengthForImageObject.php new file mode 100644 index 00000000..1ef3df14 --- /dev/null +++ b/src/Actions/FindsContentLengthForImageObject.php @@ -0,0 +1,24 @@ +image = $image; + } + + public function execute(): int + { + return 0; + } +} \ No newline at end of file diff --git a/src/Models/Image.php b/src/Models/Image.php index 77246983..7cdb7346 100644 --- a/src/Models/Image.php +++ b/src/Models/Image.php @@ -2,6 +2,8 @@ namespace Hyde\Framework\Models; +use Hyde\Framework\Actions\FindsContentLengthForImageObject; + /** * Holds the information for an image. */ @@ -98,6 +100,11 @@ public function getSource(): ?string return $this->uri ?? $this->path ?? null; } + public function getContentLength(): int + { + return (new FindsContentLengthForImageObject($this))->execute(); + } + public function getImageAuthorAttributionString(): ?string { if (isset($this->author)) { diff --git a/tests/Feature/FindsContentLengthForImageObjectTest.php b/tests/Feature/FindsContentLengthForImageObjectTest.php new file mode 100644 index 00000000..14dbe2b8 --- /dev/null +++ b/tests/Feature/FindsContentLengthForImageObjectTest.php @@ -0,0 +1,25 @@ +assertIsInt( + (new Image())->getContentLength() + ); + } +}