1<?php 2 3/** 4 * This file is part of the FreeDSx LDAP package. 5 * 6 * (c) Chad Sikorra <Chad.Sikorra@gmail.com> 7 * 8 * For the full copyright and license information, please view the LICENSE 9 * file that was distributed with this source code. 10 */ 11 12namespace FreeDSx\Ldap\Server\Paging; 13 14use FreeDSx\Ldap\Entry\Entries; 15 16/** 17 * Represents the paging response to be returned from a client paging request. 18 * 19 * @author Chad Sikorra <Chad.Sikorra@gmail.com> 20 */ 21final class PagingResponse 22{ 23 /** 24 * @var Entries 25 */ 26 private $entries; 27 28 /** 29 * @var int 30 */ 31 private $remaining; 32 33 /** 34 * @var bool 35 */ 36 private $isComplete; 37 38 /** 39 * @param Entries $entries 40 * @param bool $isComplete 41 * @param int $remaining 42 */ 43 public function __construct( 44 Entries $entries, 45 bool $isComplete = false, 46 int $remaining = 0 47 ) { 48 $this->entries = $entries; 49 $this->isComplete = $isComplete; 50 $this->remaining = $remaining; 51 } 52 53 /** 54 * @return Entries 55 */ 56 public function getEntries(): Entries 57 { 58 return $this->entries; 59 } 60 61 /** 62 * @return int 63 */ 64 public function getRemaining(): int 65 { 66 return $this->remaining; 67 } 68 69 /** 70 * @return bool 71 */ 72 public function isComplete(): bool 73 { 74 return $this->isComplete; 75 } 76 77 /** 78 * Make a standard paging response that indicates that are still results left to return. 79 * 80 * @param Entries $entries The entries returned for this response. 81 * @param int $remaining The number of entries left (if known) 82 * @return self 83 */ 84 public static function make( 85 Entries $entries, 86 int $remaining = 0 87 ): self { 88 return new self( 89 $entries, 90 false, 91 $remaining 92 ); 93 } 94 95 /** 96 * Make a final paging response indicating that there are no more entries left to return. 97 * 98 * @param Entries $entries The entries returned for this response. 99 * @return self 100 */ 101 public static function makeFinal(Entries $entries): self 102 { 103 return new self( 104 $entries, 105 true 106 ); 107 } 108} 109