public function toResource($object): ResourceObject
    {
        $context = $this->createContext(get_class($object));

        $id   = $this->identifierHandler->getIdentifier($object, $context);
        $type = $this->resolveType($object, $context);

        $resource = new ResourceObject($id, $type);

        foreach ($this->handlers as $handler)
        {
            $handler->toResource($object, $resource, $context);
        }

        return $resource;
    }
public function toResource($object): ResourceObject
    {
        $context = $this->createContext(get_class($object));

        $id   = $this->identifierHandler->getIdentifier($object, $context);
        $type = $this->resolveType($object, $context);

        $resource = new ResourceObject($id, $type);

        foreach ($this->handlers as $handler)
        {
            $handler->toResource($object, $resource, $context);
        }

        return $resource;
    }
public function toResource ( $ object ) : ResourceObject { $ context = $ this -> createContext ( get_class ( $ object ) ) ; $ id = $ this -> identifierHandler -> getIdentifier ( $ object , $ context ) ; $ type = $ this -> resolveType ( $ object , $ context ) ; $ resource = new ResourceObject ( $ id , $ type ) ; foreach ( $ this -> handlers as $ handler ) { $ handler -> toResource ( $ object , $ resource , $ context ) ; } return $ resource ; }
Map object's data to resource

@param  mixed $object
@return ResourceObject
Map object s data to resource