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

psr7 StreamWrapper #68

Closed
easy-system opened this issue Mar 3, 2016 · 3 comments
Closed

psr7 StreamWrapper #68

easy-system opened this issue Mar 3, 2016 · 3 comments

Comments

@easy-system
Copy link

It is not issue, it is rather a question. Why not add this functionality (StreamWrapper) in the very class of the stream? These classes, in fact, are wrapper?

public function __call($name, $arguments)
    {
        if (false !== strpos($name, 'stream_')) {
            $name = substr($name, 7);
        }
        $method = strtolower(str_replace('_', '', $name));
        if (! method_exists($this, $method)) {
            throw new InvalidArgumentException(
                sprintf('Method "%s" doesn\'t exist', $name)
            );
        }
        return call_user_func_array([$this, $method], $arguments);
    }
@mtdowling
Copy link
Member

mtdowling commented Mar 3, 2016 via email

@easy-system
Copy link
Author

I think the classes that implement StreamInterface, already are wrappers. Your class psr7\StreamWrapper, in fact, is the adapter. Add to your Streams method _call. Then you will not need an adapter.

@easy-system
Copy link
Author

Although, if you can decorate iterators, it is possible it is.

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

No branches or pull requests

2 participants