Skip to content

Commit f9d107d

Browse files
committed
implementing array access and fix tests
1 parent a1f7601 commit f9d107d

3 files changed

Lines changed: 12 additions & 6 deletions

File tree

‎src/Drivers/AbstractDriver.php‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace FeiMx\Pac\Drivers;
44

5+
use ArrayAccess;
56
use FeiMx\Pac\Contracts\PacDriverInterface;
67
use FeiMx\Pac\PacStamp;
78
use FeiMx\Pac\PacUser;
@@ -64,7 +65,7 @@ abstract public function addUser($rfc, $params = []): PacUser;
6465

6566
abstract public function editUser($rfc, $params = []);
6667

67-
abstract public function getUsers(): array;
68+
abstract public function getUsers(): ArrayAccess;
6869

6970
abstract public function getUser($rfc = null): PacUser;
7071

‎src/Drivers/FinkokDriver.php‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace FeiMx\Pac\Drivers;
44

5+
use ArrayAccess;
56
use FeiMx\Pac\Contracts\PacDriverInterface;
67
use FeiMx\Pac\Exceptions\PacErrorException;
78
use FeiMx\Pac\Exceptions\PacVerificationFailedException;
@@ -102,18 +103,20 @@ public function editUser($rfc, $params = [])
102103
return $response->editResult->message;
103104
}
104105

105-
public function getUsers(): array
106+
public function getUsers(): ArrayAccess
106107
{
107108
$response = $this->request($this->url('registration'), 'get', $this->prepareGenericParams(['taxpayer_id' => '']));
108109

109110
if (is_a($response, 'SoapFault')) {
110111
throw new PacErrorException($response->faultstring);
111112
}
112113

113-
$users = [];
114+
$users = collect([]);
114115
foreach ($response->getResult->users->ResellerUser as $resellerUser) {
115-
$users[] = (new PacUser())->map(
116-
$this->mapToAttributes($resellerUser)
116+
$users->push(
117+
(new PacUser())->map(
118+
$this->mapToAttributes($resellerUser)
119+
)
117120
);
118121
}
119122

‎tests/Fixtures/PacDriverStub.php‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22

33
namespace FeiMx\Pac\Tests\Fixtures;
44

5+
use ArrayAccess;
56
use FeiMx\Pac\Contracts\PacDriverInterface;
67
use FeiMx\Pac\Drivers\AbstractDriver;
78
use FeiMx\Pac\Exceptions\PacErrorException;
9+
use FeiMx\Pac\PacStamp;
810
use FeiMx\Pac\PacUser;
911

1012
class PacDriverStub extends AbstractDriver implements PacDriverInterface
@@ -33,7 +35,7 @@ public function editUser($rfc, $params = [])
3335
return (new PacUser())->map($params);
3436
}
3537

36-
public function getUsers(): array
38+
public function getUsers(): ArrayAccess
3739
{
3840
return collect(range(1, rand(5, 10)))->map(function ($index) {
3941
return (new PacUser())->map([

0 commit comments

Comments
 (0)