/** * @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(); }
/** @test */ public function it_should_transform_item_without_includes() { $userWorkplace = new UserWorkplaceEntityStub(); $userWorkplace->setName('Doe\'s Constructions'); $user = new UserEntityStub(); $user->setName('John Doe'); $user->setEmail('*****@*****.**'); $user->setWorkplace($userWorkplace); $scope = $this->transformer->transformItem($user); $this->assertInstanceOf(\League\Fractal\Scope::class, $scope); $this->assertEquals(['data' => ['name' => 'John Doe', 'email' => '*****@*****.**']], $scope->toArray()); }