@@ -343,4 +343,78 @@ protected function updatePages(int $count = null)
343343 }
344344
345345 //--------------------------------------------------------------------
346+
347+ /**
348+ * Checks to see if there is a "previous" page before our "first" page.
349+ *
350+ * @return boolean
351+ */
352+ public function hasPreviousPage (): bool
353+ {
354+ return $ this ->current > 1 ;
355+ }
356+
357+ //--------------------------------------------------------------------
358+
359+ /**
360+ * Returns a URL to the "previous" page.
361+ *
362+ * You MUST call hasPreviousPage() first, or this value may be invalid.
363+ *
364+ * @return string|null
365+ */
366+ public function getPreviousPage ()
367+ {
368+ if (!$ this ->hasPreviousPage ()) {
369+ return null ;
370+ }
371+
372+ $ uri = clone $ this ->uri ;
373+
374+ if ($ this ->segment === 0 ) {
375+ $ uri ->addQuery ($ this ->pageSelector , $ this ->current - 1 );
376+ } else {
377+ $ uri ->setSegment ($ this ->segment , $ this ->current - 1 );
378+ }
379+
380+ return (string ) $ uri ;
381+ }
382+
383+ //--------------------------------------------------------------------
384+
385+ /**
386+ * Checks to see if there is a "next" page after our "last" page.
387+ *
388+ * @return boolean
389+ */
390+ public function hasNextPage (): bool
391+ {
392+ return $ this ->current < $ this ->last ;
393+ }
394+
395+ //--------------------------------------------------------------------
396+
397+ /**
398+ * Returns a URL to the "next" page.
399+ *
400+ * You MUST call hasNextPage() first, or this value may be invalid.
401+ *
402+ * @return string|null
403+ */
404+ public function getNextPage ()
405+ {
406+ if (!$ this ->hasNextPage ()) {
407+ return null ;
408+ }
409+
410+ $ uri = clone $ this ->uri ;
411+
412+ if ($ this ->segment === 0 ) {
413+ $ uri ->addQuery ($ this ->pageSelector , $ this ->current + 1 );
414+ } else {
415+ $ uri ->setSegment ($ this ->segment , $ this ->current + 1 );
416+ }
417+
418+ return (string ) $ uri ;
419+ }
346420}
0 commit comments