src/Component.php
public function set($page = 'page', $limit = 10, $url = null)
    {
        if (is_null($url)) {
            $url = $this->page->url();
        }
        $params = $this->page->url('params', $url);
        $this->get = $page;
        $this->url = $url;
        $this->offset = 0;
        $this->limit = $limit;
        $this->total = 1;
        $this->current = 1;
        if (isset($params[$page])) {
            $page = array_map('intval', explode('of', $params[$page]));
            if (($current = array_shift($page)) && $current > 1) { // not the first page
                $this->current = $current;
                $this->offset = ($current - 1) * $this->limit;
                if (($total = array_shift($page)) && $current < $total) { // and not the last page
                    $this->total = $total;

                    return true;
                }
            }
        }

        return false;
    }
public function set($page = 'page', $limit = 10, $url = null)
    {
        if (is_null($url)) {
            $url = $this->page->url();
        }
        $params = $this->page->url('params', $url);
        $this->get = $page;
        $this->url = $url;
        $this->offset = 0;
        $this->limit = $limit;
        $this->total = 1;
        $this->current = 1;
        if (isset($params[$page])) {
            $page = array_map('intval', explode('of', $params[$page]));
            if (($current = array_shift($page)) && $current > 1) { // not the first page
                $this->current = $current;
                $this->offset = ($current - 1) * $this->limit;
                if (($total = array_shift($page)) && $current < $total) { // and not the last page
                    $this->total = $total;

                    return true;
                }
            }
        }

        return false;
    }
public function set ( $ page = 'page' , $ limit = 10 , $ url = null ) { if ( is_null ( $ url ) ) { $ url = $ this -> page -> url ( ) ; } $ params = $ this -> page -> url ( 'params' , $ url ) ; $ this -> get = $ page ; $ this -> url = $ url ; $ this -> offset = 0 ; $ this -> limit = $ limit ; $ this -> total = 1 ; $ this -> current = 1 ; if ( isset ( $ params [ $ page ] ) ) { $ page = array_map ( 'intval' , explode ( 'of' , $ params [ $ page ] ) ) ; if ( ( $ current = array_shift ( $ page ) ) && $ current > 1 ) { // not the first page $ this -> current = $ current ; $ this -> offset = ( $ current - 1 ) * $ this -> limit ; if ( ( $ total = array_shift ( $ page ) ) && $ current < $ total ) { // and not the last page $ this -> total = $ total ; return true ; } } } return false ; }
Check if we need a total count.  There's no sense in querying the database if you don't have to.  Plus, you have to call this anyways to set things up.

@param string $page  The url query parameter that pertains these records.
@param int    $limit How many records to return at a time.
@param string $url   The url to use.  The default is the current url.

@return bool

@example

```php
if (!$pagination->set()) {
$pagination->total(100);
}
```
Check if we need a total count . There s no sense in querying the database if you don t have to . Plus you have to call this anyways to set things up .