/** @test */ public function it_should_transform_null() { $this->transformer->setSerializer(new JsonApiSerializer()); // Other serializers don't handle null resource yet $scope = $this->transformer->transformNull(); $this->assertInstanceOf(\League\Fractal\Scope::class, $scope); $this->assertEquals(['data' => null], $scope->toArray()); }
/** * @return \League\Fractal\Scope */ protected function getResource() { if (null !== $this->item) { return $this->transformer->transformItem($this->item); } else { if (null !== $this->collection && false === empty($this->collection)) { return $this->transformer->transformCollection($this->collection); } } return $this->transformer->transformNull(); }