original_string: protected function extractAttributes(array $data, EntityMetadata $metadata)
      {
          $flattened = [];
          if (!isset($data['attributes']) || !is_array($data['attributes'])) {
              return $data['attributes'] = [];
          }
  
          $keyMap = array_flip(array_keys($data['attributes']));
          foreach ($metadata->getProperties() as $key => $propMeta) {
              if (!isset($keyMap[$key])) {
                  continue;
              }
              if (true === $metadata->hasAttribute($key) || true === $metadata->hasEmbed($key)) {
                  $flattened[$key] = $data['attributes'][$key];
              }
          }
          return $flattened;
      }
code: protected function extractAttributes(array $data, EntityMetadata $metadata)
      {
          $flattened = [];
          if (!isset($data['attributes']) || !is_array($data['attributes'])) {
              return $data['attributes'] = [];
          }
  
          $keyMap = array_flip(array_keys($data['attributes']));
          foreach ($metadata->getProperties() as $key => $propMeta) {
              if (!isset($keyMap[$key])) {
                  continue;
              }
              if (true === $metadata->hasAttribute($key) || true === $metadata->hasEmbed($key)) {
                  $flattened[$key] = $data['attributes'][$key];
              }
          }
          return $flattened;
      }
code_tokens: protected function extractAttributes ( array $ data , EntityMetadata $ metadata ) { $ flattened = [ ] ; if ( ! isset ( $ data [ 'attributes' ] ) || ! is_array ( $ data [ 'attributes' ] ) ) { return $ data [ 'attributes' ] = [ ] ; } $ keyMap = array_flip ( array_keys ( $ data [ 'attributes' ] ) ) ; foreach ( $ metadata -> getProperties ( ) as $ key => $ propMeta ) { if ( ! isset ( $ keyMap [ $ key ] ) ) { continue ; } if ( true === $ metadata -> hasAttribute ( $ key ) || true === $ metadata -> hasEmbed ( $ key ) ) { $ flattened [ $ key ] = $ data [ 'attributes' ] [ $ key ] ; } } return $ flattened ; }
docstring: Extracts the model's attributes, per JSON API spec.
  
  @param   array           $data
  @param   EntityMetadata  $metadata
  @return  array
docstring_tokens: Extracts the model s attributes per JSON API spec .