| @@ -29,13 +29,13 @@ | ||
| 29 | 29 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 30 | 30 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 31 | 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 32 | 32 | */ |
| 33 | -namespace Dudlewebs\WPMCS\Google\ApiCore; | |
| 33 | +namespace Dudlewebs\WPMCS\GCP\Google\ApiCore; | |
| 34 | 34 | |
| 35 | 35 | use Generator; |
| 36 | -use Dudlewebs\WPMCS\Google\Protobuf\Internal\MapField; | |
| 37 | -use Dudlewebs\WPMCS\Google\Protobuf\Internal\Message; | |
| 36 | +use Dudlewebs\WPMCS\GCP\Google\Protobuf\Internal\MapField; | |
| 37 | +use Dudlewebs\WPMCS\GCP\Google\Protobuf\Internal\Message; | |
| 38 | 38 | use IteratorAggregate; |
| 39 | 39 | /** |
| 40 | 40 | * A Page object wraps an API list method response and provides methods |
| 41 | 41 | * to retrieve additional pages using the page token. |
| @@ -41,9 +41,9 @@ | ||
| 41 | 41 | * to retrieve additional pages using the page token. |
| 42 | 42 | */ |
| 43 | 43 | class Page implements IteratorAggregate |
| 44 | 44 | { |
| 45 | - const FINAL_PAGE_TOKEN = ""; | |
| 45 | + const FINAL_PAGE_TOKEN = ''; | |
| 46 | 46 | private $call; |
| 47 | 47 | private $callable; |
| 48 | 48 | private $options; |
| 49 | 49 | private $pageStreamingDescriptor; |
| @@ -76,9 +76,9 @@ | ||
| 76 | 76 | * @return bool |
| 77 | 77 | */ |
| 78 | 78 | public function hasNextPage() |
| 79 | 79 | { |
| 80 | - return strcmp($this->getNextPageToken(), Page::FINAL_PAGE_TOKEN) != 0; | |
| 80 | + return \strcmp($this->getNextPageToken(), Page::FINAL_PAGE_TOKEN) != 0; | |
| 81 | 81 | } |
| 82 | 82 | /** |
| 83 | 83 | * Returns the next page token from the response. |
| 84 | 84 | * |
| @@ -97,15 +97,15 @@ | ||
| 97 | 97 | * is not supported by the API |
| 98 | 98 | * @throws ApiException if the call to fetch the next page fails. |
| 99 | 99 | * @return Page |
| 100 | 100 | */ |
| 101 | - public function getNextPage(int $pageSize = null) | |
| 101 | + public function getNextPage(?int $pageSize = null) | |
| 102 | 102 | { |
| 103 | 103 | if (!$this->hasNextPage()) { |
| 104 | 104 | throw new ValidationException('Could not complete getNextPage operation: ' . 'there are no more pages to retrieve.'); |
| 105 | 105 | } |
| 106 | 106 | $oldRequest = $this->getRequestObject(); |
| 107 | - $requestClass = get_class($oldRequest); | |
| 107 | + $requestClass = \get_class($oldRequest); | |
| 108 | 108 | $newRequest = new $requestClass(); |
| 109 | 109 | $newRequest->mergeFrom($oldRequest); |
| 110 | 110 | $requestPageTokenSetMethod = $this->pageStreamingDescriptor->getRequestPageTokenSetMethod(); |
| 111 | 111 | $newRequest->{$requestPageTokenSetMethod}($this->getNextPageToken()); |
| @@ -128,9 +128,9 @@ | ||
| 128 | 128 | */ |
| 129 | 129 | public function getPageElementCount() |
| 130 | 130 | { |
| 131 | 131 | $resourcesGetMethod = $this->pageStreamingDescriptor->getResourcesGetMethod(); |
| 132 | - return count($this->getResponseObject()->{$resourcesGetMethod}()); | |
| 132 | + return \count($this->getResponseObject()->{$resourcesGetMethod}()); | |
| 133 | 133 | } |
| 134 | 134 | /** |
| 135 | 135 | * Return an iterator over the elements in the response. |
| 136 | 136 | * |
| @@ -142,11 +142,11 @@ | ||
| 142 | 142 | $resourcesGetMethod = $this->pageStreamingDescriptor->getResourcesGetMethod(); |
| 143 | 143 | $items = $this->getResponseObject()->{$resourcesGetMethod}(); |
| 144 | 144 | foreach ($items as $key => $element) { |
| 145 | 145 | if ($items instanceof MapField) { |
| 146 | - yield $key => $element; | |
| 146 | + (yield $key => $element); | |
| 147 | 147 | } else { |
| 148 | - yield $element; | |
| 148 | + (yield $element); | |
| 149 | 149 | } |
| 150 | 150 | } |
| 151 | 151 | } |
| 152 | 152 | /** |
| @@ -160,12 +160,12 @@ | ||
| 160 | 160 | */ |
| 161 | 161 | public function iteratePages() |
| 162 | 162 | { |
| 163 | 163 | $currentPage = $this; |
| 164 | - yield $this; | |
| 164 | + (yield $this); | |
| 165 | 165 | while ($currentPage->hasNextPage()) { |
| 166 | 166 | $currentPage = $currentPage->getNextPage(); |
| 167 | - yield $currentPage; | |
| 167 | + (yield $currentPage); | |
| 168 | 168 | } |
| 169 | 169 | } |
| 170 | 170 | /** |
| 171 | 171 | * Gets the request object used to generate the Page. |
| @@ -203,18 +203,18 @@ | ||
| 203 | 203 | */ |
| 204 | 204 | public function expandToFixedSizeCollection($collectionSize) |
| 205 | 205 | { |
| 206 | 206 | if (!$this->pageStreamingDescriptor->requestHasPageSizeField()) { |
| 207 | - throw new ValidationException("FixedSizeCollection is not supported for this method, because " . "the method does not support an optional argument to set the " . "page size."); | |
| 207 | + throw new ValidationException('FixedSizeCollection is not supported for this method, because ' . 'the method does not support an optional argument to set the ' . 'page size.'); | |
| 208 | 208 | } |
| 209 | 209 | $request = $this->getRequestObject(); |
| 210 | 210 | $pageSizeGetMethod = $this->pageStreamingDescriptor->getRequestPageSizeGetMethod(); |
| 211 | 211 | $pageSize = $request->{$pageSizeGetMethod}(); |
| 212 | - if (is_null($pageSize)) { | |
| 213 | - throw new ValidationException("Error while expanding Page to FixedSizeCollection: No page size " . "parameter found. The page size parameter must be set in the API " . "optional arguments array, and must be less than the collectionSize " . "parameter, in order to create a FixedSizeCollection object."); | |
| 212 | + if (\is_null($pageSize)) { | |
| 213 | + throw new ValidationException('Error while expanding Page to FixedSizeCollection: No page size ' . 'parameter found. The page size parameter must be set in the API ' . 'optional arguments array, and must be less than the collectionSize ' . 'parameter, in order to create a FixedSizeCollection object.'); | |
| 214 | 214 | } |
| 215 | 215 | if ($pageSize > $collectionSize) { |
| 216 | - throw new ValidationException("Error while expanding Page to FixedSizeCollection: collectionSize " . "parameter is less than the page size optional argument specified in " . "the API call. collectionSize: {$collectionSize}, page size: {$pageSize}"); | |
| 216 | + throw new ValidationException('Error while expanding Page to FixedSizeCollection: collectionSize ' . 'parameter is less than the page size optional argument specified in ' . "the API call. collectionSize: {$collectionSize}, page size: {$pageSize}"); | |
| 217 | 217 | } |
| 218 | 218 | return new FixedSizeCollection($this, $collectionSize); |
| 219 | 219 | } |
| 220 | 220 | } |