diff --git a/src/SCIM/ListResponse.php b/src/SCIM/ListResponse.php index e54efe9..c17035b 100644 --- a/src/SCIM/ListResponse.php +++ b/src/SCIM/ListResponse.php @@ -29,19 +29,22 @@ public function toJson($options = 0) public function toSCIMArray() { - return [ - 'totalResults' => $this->totalResults, - "itemsPerPage" => count($this->resourceObjects->toArray()), - - "startIndex" => $this->startIndex, - - "nextCursor" => $this->nextCursor, - "previousCursor" => $this->previousCursor, - - "schemas" => [ - "urn:ietf:params:scim:api:messages:2.0:ListResponse" - ], - 'Resources' => Helper::prepareReturn($this->resourceObjects, $this->resourceType, $this->attributes), - ]; + return array_filter( + [ + 'totalResults' => $this->totalResults, + "itemsPerPage" => count($this->resourceObjects->toArray()), + + "startIndex" => $this->startIndex, + + "nextCursor" => $this->nextCursor, + "previousCursor" => $this->previousCursor, + + "schemas" => [ + "urn:ietf:params:scim:api:messages:2.0:ListResponse" + ], + 'Resources' => Helper::prepareReturn($this->resourceObjects, $this->resourceType, $this->attributes), + ], + fn ($value) => $value !== null + ); } }