@param Contribution $contribution

@return array - The serialized representation of a contribution
18448
public function serialize(Contribution $contribution)
    {
        $contributor = $contribution->getContributor();

        return [
            'id' => $contribution->getUuid(),
            'title' => $contribution->getTitle(),
            'text' => $contribution->getText(),
            'meta' => [
                'createdAt' => $contribution->getCreationDate()->format('Y-m-d H:i'),
                'creator' => null === $contributor ?
                    null :
                    $this->userSerializer->serialize($contributor, [Options::SERIALIZE_MINIMAL]),
            ],
        ];
    }
166487
public function getDocument($keyword)
    {
        $keyword = $this->suppressSpecialCharacterHelper->transform($keyword);
        $keywordClass = $this->keywordClass;
        $keywordEntity = $this->keywordRepository->findOneByLabel($keyword);

        if (is_null($keywordEntity)
            && !$this->authorizationChecker->isGranted(ContributionActionInterface::CREATE, KeywordInterface::ENTITY_TYPE)
        ) {
            throw new AccessDeniedHttpException();
        }
        if (is_null($keywordEntity)) {
            $keywordEntity = new $keywordClass();
            $keywordEntity->setLabel($keyword);
            $this->keywordRepository->getManager()->persist($keywordEntity);
            $this->keywordRepository->getManager()->flush($keywordEntity);
        }

        return $keywordEntity;
    }
26697
protected function serialization($value)
    {
        if (is_array($value) && !empty($value[Serializer::MAP_TYPE])) {
            $data = [];
            foreach ($value[Serializer::SCALAR_VALUE] as $v) {
                $data[] = $this->serialization($v);
            }
        } else {
            $data = $this->serializeObject($value);
        }

        return $data;
    }
1225106
public function getAcceptableEncodings(?string $default = null): array
	{
		if(!isset($this->acceptableEncodings))
		{
			$this->acceptableEncodings = $this->parseAcceptHeader($this->get('accept-encoding'));
		}

		return $this->acceptableEncodings ?: (array) $default;
	}
747421
public function toArray($request)
    {
        return [
            'id'            => (int) $this->id,
            'author_id'     => $this->author_id,
            'language_code' => $this->language_code,
            'title'         => $this->title,
            'body'          => $this->body,
            'custom_fields' => $this->custom_fields,
            'is_active'     => $this->is_active,
            'created_at'    => $this->created_at->toIso8601String(),
            'updated_at'    => $this->updated_at->toIso8601String(),
        ];
    }
1209172
public function toArray($request)
    {
        /** @var \Unite\Transactions\Models\Transaction $this->resource */
        return [
            'id'                 => $this->id,
            'type'               => $this->type,
            'subject_type'       => $this->subject_type,
            'subject_id'         => $this->subject_id,
            'amount'             => $this->amount,
            'balance'            => $this->balance,
            'variable_symbol'    => (int)$this->variable_symbol,
            'specific_symbol'    => (int)$this->specific_symbol,
            'description'        => $this->description,
            'posted_at'          => (string)$this->posted_at,
            'created_at'         => (string)$this->created_at,
            'destination_iban'   => $this->destination_iban,
            'transaction_source' => new SourceResource($this->source)
        ];
    }
550579
public function serialize(Scorm $scorm)
    {
        return [
            'id' => $scorm->getUuid(),
            'version' => $scorm->getVersion(),
            'hashName' => $scorm->getHashName(),
            'ratio' => $scorm->getRatio(),
            'scos' => $this->serializeScos($scorm),
        ];
    }
347110
public function serialize(User $user)
    {
        return [
            self::SERIALIZED_USER_USERNAME_KEY => $this->encrypt($user->getUsername(), $this->surrogateKey),
            self::SERIALIZED_USER_PASSWORD_KEY => $this->encrypt($user->getPassword(), $this->surrogateKey),
            self::SERIALIZED_USER_KEY_KEY => $this->encrypt($this->surrogateKey, $this->key),
        ];
    }
958859
public function toArray()
	{
		return [
			'name' => SerializationHelper::stringOrNull($this->name),
			'cmt' => SerializationHelper::stringOrNull($this->comment),
			'desc' => SerializationHelper::stringOrNull($this->description),
			'src' => SerializationHelper::stringOrNull($this->source),
			'link' => SerializationHelper::serialize($this->links),
			'number' => SerializationHelper::integerOrNull($this->number),
			'type' => SerializationHelper::stringOrNull($this->type),
			'extensions' => SerializationHelper::serialize($this->extensions),
			'rtep' => SerializationHelper::serialize($this->points),
			'stats' => SerializationHelper::serialize($this->stats)
		];
	}
54871
protected function basicSerialize()
    {
        return [
            'type' => $this->getEventType(),
            'transaction' => $this->transactionId,
            'primary_key' => $this->id,
            'source' => $this->source,
            'parent_source' => $this->parentSource,
            '@timestamp' => $this->timestamp,
            'meta' => $this->meta
        ];
    }
647728
public function getArray( $post_id, $contributor_type ) {
		if ( ! str_starts_with( $contributor_type, 'pb_' ) ) {
			$contributor_type = 'pb_' . $contributor_type;
		}
		if ( ! $this->isValid( $contributor_type ) ) {
			return [];
		}

		// Look if contributors exist as taxonomies (new data model)
		$contributors = [];
		$meta = get_post_meta( $post_id, $contributor_type, false );
		if ( is_array( $meta ) ) {
			foreach ( $meta as $slug ) {
				$name = $this->personalName( $slug );
				if ( $name ) {
					$contributors[] = $name;
				}
			}
		}

		if ( empty( $contributors ) ) {
			// Look if contributors exist as metadata (old data model)
			// If yes then convert to taxonomies (new data model)
			$map = [
				'pb_authors' => [ 'pb_author', 'pb_section_author', 'pb_author_file_as' ],
				'pb_editors' => [ 'pb_editor' ],
				'pb_translators' => [ 'pb_translator' ],
				'pb_contributors' => [ 'pb_contributing_authors' ],
			];
			if ( isset( $map[ $contributor_type ] ) ) {
				foreach ( $map[ $contributor_type ] as $slug ) {
					$meta = get_post_meta( $post_id, $slug, false );
					if ( is_array( $meta ) ) {
						foreach ( $meta as $name ) {
							$result = $this->insert( $name );
							if ( $result !== false ) {
								$added = $this->link( $result['term_id'], $post_id, $contributor_type );
								if ( $added !== false ) {
									$contributors[] = $name;
									delete_post_meta( $post_id, $slug, $name );
								}
							}
						}
					}
				}
			}
		}

		return $contributors;
	}
1038717
public function serialize(Resource $resource)
    {
        return [
            'id' => $resource->getUuid(),
            'name' => $resource->getName(),
            'resourceType' => $this->resourceTypeSerializer->serialize($resource->getResourceType()),
            'maxTimeReservation' => $resource->getMaxTimeReservation(),
            'description' => $resource->getDescription(),
            'localization' => $resource->getLocalisation(),
            'quantity' => $resource->getQuantity(),
            'color' => $resource->getColor(),
            'organizations' => $this->getOrganizations($resource),
            'resourceRights' => $this->getResourceRights($resource),
        ];
    }
958122
private function fromCompactSerializationSignatureToSerialization(array $parts)
    {
        $temp = [];

        if (!empty($parts[1])) {
            $temp['payload'] = $parts[1];
        }
        $temp['signatures'] = [[
            'protected' => $parts[0],
            'signature' => $parts[2],
        ]];

        return $temp;
    }
498035
public function toArray($request)
    {
        return [
            'id'           => (int) $this->id,
            'author_id'    => $this->author_id,
            'type'         => $this->whenLoaded('type', function () {
                return $this->type->name;
            }),
            'region'       => $this->region,
            'theme'        => $this->theme,
            'weight'       => $this->weight,
            'filter'       => $this->filter,
            'options'      => $this->options,
            'is_active'    => $this->is_active,
            'is_cacheable' => $this->is_cacheable,
            'created_at'   => $this->created_at->toIso8601String(),
            'updated_at'   => $this->updated_at->toIso8601String(),
            'translations' => BlockTranslation::collection($this->whenLoaded('translations')),
        ];
    }
1252027
public function createAndSetCsrfCookie($val)
    {
        $masked = $this->client->maskToken($val);
        $name = $this->client->getCsrfParamName();
        $this->setCookie($name, $val);
        return [$name, $masked];
    }
215071
private function writeContributors(array $contributors)
    {
        $nameColumnSize = max(array_map('strlen', array_values($contributors)));
        $columns        = sprintf('%s  GitHub Username', str_pad('Name', $nameColumnSize));

        $this->output->writeLine($columns);
        $this->output->writeLine(str_repeat('-', strlen($columns)));

        foreach ($contributors as $gitHubUser => $name) {
            $this->output->writeLine(sprintf("%s  %s", str_pad($name, $nameColumnSize), $gitHubUser));
        }
    }
82393
protected function extractTypeHintFromComment($comment)
    {
        if (empty($comment)) {
            return [null, null];
        }

        if (!preg_match('(\(DC2Type:(\w+)\))', $comment, $match)) {
            return [null, $comment];
        }

        $type    = $match[1];
        $comment = trim(str_replace('(DC2Type:' . $type . ')', '', $comment));

        if ($comment == '') {
            $comment = null;
        }

        return [$type, $comment];
    }