/**
  * @param array $value
  *
  * @return array
  */
 protected function serialization(array &$value)
 {
     $data = [self::DATA_KEY => \array_merge(PropertyHelper::setResponseDataTypeAndId($this->mappings, $value), DataAttributesHelper::setResponseDataAttributes($this->mappings, $value), DataLinksHelper::setResponseDataLinks($this->mappings, $value), DataLinksHelper::setResponseDataRelationship($this->mappings, $value, $value))];
     DataIncludedHelper::setResponseDataIncluded($this->mappings, $value, $data);
     $this->setResponseLinks($value, $data);
     $this->setResponseMeta($data);
     $this->setResponseVersion($data);
     return $data;
 }
 /**
  * @param array  $mappings
  * @param array  $data
  * @param array  $value
  * @param string $type
  */
 protected static function addRelationshipsToIncludedResources(array &$mappings, array &$data, array &$value, $type)
 {
     foreach ($value as $propertyName => $attribute) {
         if (PropertyHelper::isAttributeProperty($mappings, $propertyName, $type)) {
             $propertyName = DataAttributesHelper::transformToValidMemberName($propertyName);
             if (\is_array($attribute) && \array_key_exists(Serializer::CLASS_IDENTIFIER_KEY, $attribute)) {
                 $data[$propertyName][JsonApiTransformer::DATA_KEY] = PropertyHelper::setResponseDataTypeAndId($mappings, $attribute);
                 continue;
             }
         }
     }
 }
 /**
  * @param \NilPortugues\Api\Mapping\Mapping[] $mappings
  * @param array                               $parent
  * @param string                              $propertyName
  * @param string                              $type
  * @param array                               $data
  * @param array                               $value
  */
 protected static function relationshipLinksSelf(array &$mappings, array &$parent, $propertyName, $type, array &$data, array &$value)
 {
     if (!in_array($propertyName, RecursiveFormatterHelper::getIdProperties($mappings, $type), true)) {
         $data[JsonApiTransformer::RELATIONSHIPS_KEY][$propertyName] = array_merge(array_filter([JsonApiTransformer::LINKS_KEY => self::setResponseDataRelationshipSelfLinks($propertyName, $mappings, $parent)]), array_filter([JsonApiTransformer::DATA_KEY => PropertyHelper::setResponseDataTypeAndId($mappings, $value)]));
         if (count($data[JsonApiTransformer::RELATIONSHIPS_KEY][$propertyName]) === 0) {
             unset($data[JsonApiTransformer::RELATIONSHIPS_KEY][$propertyName]);
         }
     }
 }
 /**
  * @param \NilPortugues\Api\Mapping\Mapping[] $mappings
  * @param string                              $type
  * @param string                              $keyName
  * @param array                               $value
  * @param array                               $attributes
  */
 protected static function addIdPropertiesInAttribute(array &$mappings, $type, $keyName, array $value, array &$attributes)
 {
     $keepKeys = str_replace(array_values($mappings[$type]->getAliasedProperties()), array_keys($mappings[$type]->getAliasedProperties()), $mappings[$type]->getFilterKeys());
     $keepIdKeys = 0 === count($keepKeys);
     if (false !== array_search($keyName, $keepKeys, true)) {
         $keepIdKeys = false;
     }
     if ($keepIdKeys) {
         $ids = PropertyHelper::getIdValues($mappings, $value, $type);
         if (count($ids) > 0) {
             if (1 === count($ids)) {
                 $ids = array_pop($ids);
             }
             $attributes[$keyName] = $ids;
         } else {
             RecursiveFormatterHelper::formatScalarValues($value);
             $attributes[$keyName] = $value;
         }
     }
 }