Skip to content

Commit

Permalink
Using is_countable to avoid count with null
Browse files Browse the repository at this point in the history
  • Loading branch information
peter279k committed Sep 20, 2023
1 parent 26c70be commit 4ee229e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Payloads/ModelPayload.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function getContent(): array

$relations = $this->model->relationsToArray();

if (count($relations)) {
if (is_countable($relations) ? count($relations) : 0) {
$content['relations'] = ArgumentConverter::convertToPrimitive($relations);
}

Expand Down
2 changes: 1 addition & 1 deletion tests/RayTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
expect($payloads[0]['payloads'][0]['content']['values']['APP_ENV'])->toEqual('local');
expect($payloads[0]['payloads'][0]['content']['values']['DB_DATABASE'])->toEqual('ray_test');
expect($payloads[0]['payloads'][0]['content']['values']['SESSION_LIFETIME'])->toEqual('120');
expect(count($payloads[0]['payloads'][0]['content']['values']))->toBeGreaterThanOrEqual(17);
expect(is_countable($payloads[0]['payloads'][0]['content']['values']) ? count($payloads[0]['payloads'][0]['content']['values']) : 0)->toBeGreaterThanOrEqual(17);
});

it('sends a filtered environment payload', function () {
Expand Down

0 comments on commit 4ee229e

Please sign in to comment.