Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fluent Interface? #17

Open
chrischi1989 opened this issue Jan 6, 2015 · 2 comments
Open

Fluent Interface? #17

chrischi1989 opened this issue Jan 6, 2015 · 2 comments

Comments

@chrischi1989
Copy link

Can you provide a fluent interface like this?

FTP::connection('foo')->changeDir('bar')
                      ->makeDir('abc')
                      ->changeDir('abc')
                      ->uploadFile('foobar.txt', 'barfoo.txt')
                      ->getDirListing();

It's not a necessity but I think this would improve the ease of use.

Greetings from Germany
Christian

@harishanchu
Copy link
Owner

HI Christian,

Thanks for your suggestion, but there is a problem in implementing this. Since FTP methods won't result in success always, which will cause errors in the program when we implement an interface like this.
For example, in the case you have shown a number of methods will execute sequentially independent of whether the previous method execution is success or failure, which is not good.
Please let me know your thoughts.

Thanks

@chrischi1989
Copy link
Author

Hi there,

Just pressed the wrong button...o_O

One approach might be using the methods to build up a command stack and add a method for executing the stack. The FTP functions you're currently using return false or -1 if they fail and if they do so, you might utilize the MessageBag Class of Laravel instead of returning false.

Then you'll be able to provide more detailed error messages and the developers can check themselfs if the MessageBag is empty or not.

Greetings

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

No branches or pull requests

2 participants