Art4\JsonApiClient\AccessInterface::get PHP Method

get() public method

public get ( $key )
    public function get($key);

Usage Example

 /**
  * Parses the data for this element
  *
  * @param mixed $object The data
  *
  * @return self
  *
  * @throws ValidationException
  */
 public function parse($object)
 {
     if (!is_object($object)) {
         throw new ValidationException('RelationshipLink has to be an object, "' . gettype($object) . '" given.');
     }
     if (!property_exists($object, 'self') and !property_exists($object, 'related')) {
         throw new ValidationException('RelationshipLink has to be at least a "self" or "related" link');
     }
     $links = get_object_vars($object);
     if (array_key_exists('self', $links)) {
         if (!is_string($links['self'])) {
             throw new ValidationException('property "self" has to be a string, "' . gettype($links['self']) . '" given.');
         }
         $this->container->set('self', strval($links['self']));
         unset($links['self']);
     }
     if (array_key_exists('related', $links)) {
         if (!is_string($links['related']) and !is_object($links['related'])) {
             throw new ValidationException('property "related" has to be a string or object, "' . gettype($links['related']) . '" given.');
         }
         $this->setLink('related', $links['related']);
         unset($links['related']);
     }
     // Pagination links
     if ($this->parent->has('data') and $this->parent->get('data') instanceof ResourceIdentifierCollectionInterface) {
         if (array_key_exists('first', $links)) {
             $this->setPaginationLink('first', $links['first']);
             unset($links['first']);
         }
         if (array_key_exists('last', $links)) {
             $this->setPaginationLink('last', $links['last']);
             unset($links['last']);
         }
         if (array_key_exists('prev', $links)) {
             $this->setPaginationLink('prev', $links['prev']);
             unset($links['prev']);
         }
         if (array_key_exists('next', $links)) {
             $this->setPaginationLink('next', $links['next']);
             unset($links['next']);
         }
     }
     // custom links
     foreach ($links as $name => $value) {
         $this->setLink($name, $value);
     }
 }