Tustin / psn-php

A PHP wrapper for the PSN API
https://tustin.dev/psn-php/
MIT License
354 stars 73 forks source link

Search on store fix #206

Closed gabetavares closed 2 years ago

gabetavares commented 2 years ago

Store Search Iterator

DivisionByZeroError

The first problem I found was the $limit variable has not been set in StoreFactoryIterator causing the modulo always a division by zero. I chose to keep the limit of 20 because this is the pageSize limit. Also change the 'pageSize' => 20 to 'pageSize' => $limit on access() method.

maxEventIndexCursor

The next problem was the maxEventIndexCursor, there is neither a property nor a method called maxEventIndexCursor, changing the undefined variable to customCursor which is a valid property containing the cursor it keeps the pagination until the end.

Undefined concept ID

The problem here is a bit simple, I got into a similar one crawling through the Chihiro API.

Some content, when querying data through the API could be DISC ONLY or DISC BASED GAME in storePrimaryClassification, it commonly happens in expansions from Rock Band but happens in other old games, as far as I know recent games does not have this problem.

An easy fix is just check if it exists before calling Concept and pass 0 or null in case it does not exist, all the other data will be fetched equally except for conceptID.

The search I made was:

$product = $client->store()->search('crash');

Unit Test

I made a unit test also, but since I'm not so familiar with mocking classes, I think it is a pretty weak test and probably inefficient.

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.