Skip to content

Add process builder#8

Open
millancore wants to merge 2 commits intosquare1-io:masterfrom
millancore:master
Open

Add process builder#8
millancore wants to merge 2 commits intosquare1-io:masterfrom
millancore:master

Conversation

@millancore
Copy link

@millancore millancore commented Nov 22, 2024

As not all process parameters are needed, a builder is added to make it visually simpler and there is no need to use null values.

E.g Add output format "webp'

Now:

$img = $resized->process('http://www.example.com/some-image.jpg', '100', '', '', ['output' => 'webp', 'quality' => 90]);

With Builder:

$img = $resized->src('http://www.example.com/some-image.jpg')
    ->width(100)
    ->quality(90)
    ->output('webp')
    ->url();

@jeffochoa
Copy link
Contributor

I like the idea, the fluent api certainly is an improvement.

There are a couple of structural issues we'd need to address first:

  1. The Builder is only acting as a proxy to the Image::class so it feels redundant, I think you can simplify this and keep only one class (maybe just the Builder?).

  2. On the Reszed:class maybe just rename the builder()' method to src()` so it reads like:

$resized->src('image.jpg')->width(100)->url();
  1. On the ProcessBuilder::class you have a process() method:
return ProcessBuilder::new($this)->process($url);

But this method isn't actually processing anything, is only creating a new instance of the Image::class. I think solving #1 will resolve this issue as well.

@millancore
Copy link
Author

I like the idea, it simpler, I will make the changes. thanks @jeffochoa

@millancore
Copy link
Author

Updated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants