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

Extend Result with more helpers #20

Open
h4cc opened this issue Jul 9, 2015 · 1 comment
Open

Extend Result with more helpers #20

h4cc opened this issue Jul 9, 2015 · 1 comment

Comments

@h4cc
Copy link
Contributor

h4cc commented Jul 9, 2015

I added some more helpers to the Result class, like this:

    public function getFirstDoc()
    {
        $row = $this->getFirstRow();

        return $row ? $row['doc'] : false;
    }

    public function getDocs()
    {
        return array_map(function($row) {
            return $row['doc'];
        }, $this->getRows());
    }

    public function isEmpty()
    {
        return !(bool)$this->data['rows'];
    }

    public function isError()
    {
        return array_key_exists('error', $this->data);
    }

    public function isNotFound()
    {
        return $this->isError() && ($this->data['error'] == 'not_found');
    }

Maybe these could be usefull in your Result class.

@Baachi
Copy link
Owner

Baachi commented Jul 11, 2015

The result class isn't really finished yet. Submit a PR, i will review and merge it :)

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