@@ -313,11 +313,11 @@ public function getTools(?int $limit = null, ?string $cursor = null): array
313313 foreach ($ this ->tools as $ toolReference ) {
314314 $ tools [] = $ toolReference ->tool ;
315315 }
316-
317- if ($ limit === null ) {
316+
317+ if (null === $ limit ) {
318318 return $ tools ;
319319 }
320-
320+
321321 return $ this ->paginateResults ($ tools , $ limit , $ cursor );
322322 }
323323
@@ -330,11 +330,11 @@ public function getResources(?int $limit = null, ?string $cursor = null): array
330330 foreach ($ this ->resources as $ resource ) {
331331 $ resources [] = $ resource ->schema ;
332332 }
333-
334- if ($ limit === null ) {
333+
334+ if (null === $ limit ) {
335335 return $ resources ;
336336 }
337-
337+
338338 return $ this ->paginateResults ($ resources , $ limit , $ cursor );
339339 }
340340
@@ -347,11 +347,11 @@ public function getPrompts(?int $limit = null, ?string $cursor = null): array
347347 foreach ($ this ->prompts as $ promptReference ) {
348348 $ prompts [] = $ promptReference ->prompt ;
349349 }
350-
351- if ($ limit === null ) {
350+
351+ if (null === $ limit ) {
352352 return $ prompts ;
353353 }
354-
354+
355355 return $ this ->paginateResults ($ prompts , $ limit , $ cursor );
356356 }
357357
@@ -360,36 +360,36 @@ public function getPrompts(?int $limit = null, ?string $cursor = null): array
360360 */
361361 public function getToolsCount (): int
362362 {
363- return count ($ this ->tools );
363+ return \ count ($ this ->tools );
364364 }
365365
366366 /**
367367 * Get total count of prompts.
368368 */
369369 public function getPromptsCount (): int
370370 {
371- return count ($ this ->prompts );
371+ return \ count ($ this ->prompts );
372372 }
373373
374374 /**
375375 * Get total count of resources.
376376 */
377377 public function getResourcesCount (): int
378378 {
379- return count ($ this ->resources );
379+ return \ count ($ this ->resources );
380380 }
381381
382- /**
383- * @return array<string, ResourceTemplate>
382+ /**
383+ * @return array<string, ResourceTemplate>
384384 */
385385 public function getResourceTemplates (?int $ limit = null , ?string $ cursor = null ): array
386386 {
387387 $ templates = array_map (fn ($ template ) => $ template ->resourceTemplate , $ this ->resourceTemplates );
388-
389- if ($ limit === null ) {
388+
389+ if (null === $ limit ) {
390390 return $ templates ;
391391 }
392-
392+
393393 return $ this ->paginateResults ($ templates , $ limit , $ cursor );
394394 }
395395
@@ -399,22 +399,22 @@ public function getResourceTemplates(?int $limit = null, ?string $cursor = null)
399399 private function paginateResults (array $ items , int $ limit , ?string $ cursor = null ): array
400400 {
401401 $ offset = 0 ;
402- if ($ cursor !== null ) {
402+ if (null !== $ cursor ) {
403403 $ decodedCursor = base64_decode ($ cursor , true );
404404
405- if ($ decodedCursor === false || !is_numeric ($ decodedCursor )) {
405+ if (false === $ decodedCursor || !is_numeric ($ decodedCursor )) {
406406 throw new InvalidCursorException ($ cursor );
407407 }
408-
408+
409409 $ offset = $ decodedCursor ;
410-
410+
411411 // Validate offset is within reasonable bounds
412- if ($ offset < 0 || $ offset > count ($ items )) {
412+ if ($ offset < 0 || $ offset > \ count ($ items )) {
413413 throw new InvalidCursorException ($ cursor );
414414 }
415415 }
416416
417- return array_slice ($ items , $ offset , $ limit );
417+ return \ array_slice ($ items , $ offset , $ limit );
418418 }
419419
420420 /**
@@ -424,20 +424,20 @@ public function calculateNextCursor(int $totalCount, ?string $currentCursor, int
424424 {
425425 $ currentOffset = 0 ;
426426
427- if ($ currentCursor !== null ) {
427+ if (null !== $ currentCursor ) {
428428 $ decodedCursor = base64_decode ($ currentCursor , true );
429- if ($ decodedCursor !== false && is_numeric ($ decodedCursor )) {
429+ if (false !== $ decodedCursor && is_numeric ($ decodedCursor )) {
430430 $ currentOffset = $ decodedCursor ;
431431 }
432432 }
433-
433+
434434 $ nextOffset = $ currentOffset + $ returnedCount ;
435-
435+
436436 // If we have more items available, return next cursor
437437 if ($ nextOffset < $ totalCount ) {
438438 return base64_encode ((string ) $ nextOffset );
439439 }
440-
440+
441441 return null ;
442442 }
443443}
0 commit comments