getId() public méthode

Get the resource ID.
public getId ( ) : string
Résultat string
Exemple #1
0
 /**
  * @param Resource[] $resources
  * @param Resource $newResource
  * @return Resource[]
  */
 protected function mergeResource(array $resources, Resource $newResource)
 {
     $type = $newResource->getType();
     $id = $newResource->getId();
     foreach ($resources as $resource) {
         if ($resource->getType() === $type && $resource->getId() === $id) {
             $resource->merge($newResource);
             return $resources;
         }
     }
     $resources[] = $newResource;
     return $resources;
 }
 public function testGetIdWorksWithScalarData()
 {
     $resource = new Resource(123, new PostSerializer4());
     $this->assertSame('123', $resource->getId());
 }
 /**
  * @param Resource[] $resources
  * @param Resource $newResource
  * @return Resource[]
  */
 protected function mergeResource(array $resources, Resource $newResource)
 {
     $type = $newResource->getType();
     $id = $newResource->getId();
     if (isset($resources[$type][$id])) {
         $resources[$type][$id]->merge($newResource);
     } else {
         $resources[$type][$id] = $newResource;
     }
     return $resources;
 }