@param array $value

@return array
767355
protected function serializeObject(array $value)
    {
        $this->guardMappedClass($value);

        $value = $this->preSerialization($value);
        $data = $this->serialization($value);

        return $this->postSerialization($data);
    }
1221268
private function getValueType(array $value)
    {
        $keys = array_keys($value);
        $types = array_values(array_filter($keys, function ($key) {
            return strpos($key, 'Value') !== false;
        }));

        if (!empty($types)) {
            return $types[0];
        }

        throw new \RuntimeException('Invalid entity property value given');
    }
912287
public function reverseTransform($value)
    {
        $result = array();
        if (is_array($value)) {
            array_walk_recursive($value, function($item, $key) use (&$result) {
                if ($item) {
                    $result[] = $key;
                }
            });
        }

        return $result;
    }
1075679
public function getUserValue($value)
    {
        if (! is_array($value)) {
            if ('' == $value) {
                $value = [];
            } else {
                $value = explode($this->getSeparator(), $value);
            }
        }

        return $value;
    }
855023
public function apply(Value $value): array
    {
        if ($value->isEmpty()) {
            return $this->filtered(Secret::forNull());
        }

        return $this->filtered(Secret::create($value->value()));
    }
214494
public static function convertToDb($value)
    {
        if (!is_array($value)) {
            return [];
        }

        // see DateType::convertToDatabaseValue()
        $convertor = function ($value) {
            if ($value === null || $value instanceof \MongoDate) {
                return $value;
            }

            try {
                $datetime = DateType::getDateTime($value);
                return new \MongoDate($datetime->format('U'), $datetime->format('u'));
            } catch (\InvalidArgumentException $e) {
                return null;
            }
        };

        return array_values(array_filter(array_map($convertor, $value)));
    }
1163366
protected function getPossibleTypes($value): array
    {
        $type = $this->getTypeOf($value);

        switch ($type) {
            case 'boolean':
            case 'integer':
            case 'float':
            case 'string':
                return $this->getPossibleScalarTypes($value);
            case 'array':
                return $this->getPossibleArrayTypes($value);
            case 'assoc':
                return $this->getPossibleAssocTypes($value);
            case 'object':
                return $this->getPossibleObjectTypes($value);
            case 'resource':
            default:
                return array_intersect($this->types, [$type]);
        }
    }
532203
public function createAttachments(array $value): array
    {
        return array_map(function ($data) {
            if ($data instanceof ResourceAttachment) {
                return $data;
            }

            return new ResourceAttachment((array) $data);
        }, $value);
    }
1174514
private function escapeArray($value) {
        if (!is_array($value)) {
            return $this->escape($value);
        }
        foreach ($value as $key => $prop) {
            $value[$key] = $this->escape($prop);
        }
        return $value;
    }
564589
public function createAttempts($value): array
    {
        return array_map(function ($data) {
            if ($data instanceof PaymentRetryAttempt) {
                return $data;
            }

            return new PaymentRetryAttempt((array) $data);
        }, $value);
    }
334152
protected function serializeArray(array $value)
    {
        if (\array_key_exists(self::MAP_TYPE, $value)) {
            return $value;
        }

        $toArray = [self::MAP_TYPE => 'array', self::SCALAR_VALUE => []];
        foreach ($value as $key => $field) {
            $toArray[self::SCALAR_VALUE][$key] = $this->serializeData($field);
        }

        return $this->serializeData($toArray);
    }
957480
protected function valueToJsonLd($value)
    {
        if (is_array($value)) {
            $return = [];
            foreach ($value as $item) {
                $return[] = $this->valueToJsonLd($item);
            }

            return $return;
        } elseif ($value instanceof Type\EnumerationType || $value instanceof Type\Enumeration) {
            return $value->getSchemaUrl();
        } elseif ($value instanceof Type\TypeInterface) {
            return $this->typeToJsonLd($value);
        } elseif ($value instanceof Property\PropertyInterface) {
            return $this->propertyToJsonLd($value);
        } elseif ($value instanceof DataType\DataTypeInterface) {
            return $this->dataTypeToJsonLd($value);
        }

        throw new \Exception('Unexpected data type '.gettype($value));
    }
1065290
public function transform($value)
    {
        if (null === $value) {
            return array();
        }
        if($this->identifier){
            return $this->identifier->getValue($value);
        }

        return $value->getId();
    }
487596
protected function preSerialization(array $value)
    {
        /** @var \NilPortugues\Api\Mapping\Mapping $mapping */
        foreach ($this->mappings as $class => $mapping) {
            RecursiveDeleteHelper::deleteProperties($this->mappings, $value, $class);
            RecursiveRenamerHelper::renameKeyValue($this->mappings, $value, $class);
        }

        return $value;
    }
789743
protected function prepareArrayValue(array $value)
    {
        $rii = new \RecursiveIteratorIterator(
            new \RecursiveArrayIterator($value),
            \RecursiveIteratorIterator::SELF_FIRST
        );
        foreach ($rii as $key => $value) {
            if (($value instanceof ValueGenerator) === false) {
                $value = new self($value);
                $rii->getSubIterator()->offsetSet($key, $value);
            }

            $value->setIndentationLevel($value->getIndentationLevel() + $rii->getDepth());
        }

        return $rii->getSubIterator()->getArrayCopy();
    }
1344641
private function parse($value): array
    {
        if (is_array($value)) {
            if ($value[0] !== $value[1]) {
                return $this->error('PASSWORDS_NOT_EQUAL');
            }

            $value = $value[0];
        }

        if (empty($value) === 0) {
            return [null, []];
        }

        return [Secret::create($value), []];
    }
503605
protected static function export(array $value)
	{
		$pairs = [];
		foreach ($value as $k => $v)
		{
			$pairs[] = var_export($k, true) . '=>' . var_export($v, true);
		}

		return '[' . implode(',', $pairs) . ']';
	}