@param Collection $value

@return array
330028
protected function serializeEloquentCollection(Collection $value)
    {
        $items = [];
        foreach ($value as $v) {
            $items[] = $this->serializeObject($v);
        }

        return [self::MAP_TYPE => 'array', self::SCALAR_VALUE => $items];
    }
197160
private function encodeObjectValue($value)
    {
        if ($value instanceof \stdClass) {
            return $this->encodeAssociativeArrayValue((array) $value);
        }

        if ($value instanceof Blob) {
            return ['bytesValue' => (string) $value];
        }

        if ($value instanceof \DateTimeInterface) {
            return [
                'timestampValue' => [
                    'seconds' => $value->format('U'),
                    'nanos' => (int)($value->format('u') * 1000)
                ]
            ];
        }

        if ($value instanceof Timestamp) {
            return [
                'timestampValue' => [
                    'seconds' => $value->get()->format('U'),
                    'nanos' => $value->nanoSeconds()
                ]
            ];
        }

        if ($value instanceof GeoPoint) {
            return ['geoPointValue' => $value->point()];
        }

        if ($value instanceof DocumentReference || $value instanceof DocumentSnapshot) {
            return ['referenceValue' => $value->name()];
        }

        throw new \RuntimeException(sprintf(
            'Object of type %s cannot be encoded to a Firestore value type.',
            get_class($value)
        ));
    }
244175
public function __toArray($value = null)
    {
        $value = is_null($value) ? $this->items : $value;

        if (!$this->isArrayable($value)) {
            return $value;
        }

        $result = array_map(function ($value) {
            if ($this->isArrayable($value)) {
                return $this->__toArray($value);
            }

            return $value;
        }, $this->getArrayableItems($value));

        return $result;
    }
155042
protected function coerceArrayValue(string $format, $value): array
    {
        switch ($format) {
            case 'csv':
                return explode(',', $value);
            case 'ssv':
                return explode(' ', $value);
            case 'tsv':
                return explode("\t", $value);
            case 'pipes':
                return explode('|', $value);
            default:
                throw new \RuntimeException(
                    "Array 'collectionFormat' '$format' is not currently supported"
                );
        }
    }
758040
protected function convertToArray($value)
    {
        if (\is_string($value)) {
            $value = [$value];
        } elseif (null === $value) {
            $value = [];
        }

        return $value;
    }
625113
public function convert($value)
    {
        if (!is_object($value)) {
            return $value;
        }

        if ($value instanceof Collection) {
            return $value->map(function ($item) {
                return $this->formatter($item)->format($item);
            })->toArray();
        }

        return $this->formatter($value)->format($value);
    }
1098392
public function filter($value)
    {
        return in_array($value, $this->getList(), $this->getStrict()) ? $value : null;
    }
467778
public function get($value)
    {
        return isset($this->items[$value]) ? $this->items[$value] : null;
    }
1012047
public function apply(Value $value): array
    {
        if ($value->isEmpty()) {
            return $this->filtered(new Token(null));
        }

        $value = $value->value();
        if (strtolower(trim(substr($value, 0, 7))) === 'bearer') {
            return $this->filtered(new Token(substr($value, 7)));
        }

        return $this->filtered(new Token($value));
    }
996862
protected function findEntity($value)
    {
        $result = $this->finder->{$this->findMethod}($value);

        if ($result === null) {
            return [];
        }

        return (array) $result;
    }
641906
protected function is_collection_like($value)
    {
        if ($value instanceof self) {
            return true;

        } else if ($value instanceof \Traversable) {
            return true;

        } else if ($value instanceof Arrayable) {
            return true;

        } else if ($value instanceof Jsonable) {
            return true;

        } else if (is_object($value) || is_array($value)) {
            return true;

        } else {
            return false;
        }
    }
311272
public function transform($value)
    {
        $result = array();
        $workflowProfiles = $this->workflowProfileRepository->findAll();
        $contentTypes = $this->contentTypeRepository->findAllNotDeletedInLastVersion();

        $settedWorkflowProfiles = array();
        if ($value instanceof Collection) {
            foreach ($value as $workflowProfileCollectionName => $workflowProfileCollection) {
                $settedWorkflowProfiles[$workflowProfileCollectionName] = array();
                foreach ($workflowProfileCollection->getProfiles() as $workflowProfile) {
                    $settedWorkflowProfiles[$workflowProfileCollectionName][] = $workflowProfile->getId();
                }
            }
        }
        foreach ($workflowProfiles as $workflowProfile) {
            $nodeTypeId = NodeInterface::ENTITY_TYPE;
            $result[$nodeTypeId][$workflowProfile->getId()] = array_key_exists($nodeTypeId, $settedWorkflowProfiles) && in_array($workflowProfile->getId(), $settedWorkflowProfiles[$nodeTypeId]);
        }

        foreach ($contentTypes as $contentType) {
            $contentTypeId = $contentType->getContentTypeId();
            foreach ($workflowProfiles as $workflowProfile) {
                $result[$contentTypeId][$workflowProfile->getId()] = array_key_exists($contentTypeId, $settedWorkflowProfiles) && in_array($workflowProfile->getId(), $settedWorkflowProfiles[$contentTypeId]);
            }
        }

        return $result;
    }
359703
protected function getPossibleArrayTypes(array $value): array
    {
        $noSubTypes = in_array('array', $this->types);

        $types = array_filter($this->types, function($type) use($noSubTypes) {
            return $type === 'array'
                || (!$noSubTypes && substr($type, -2) === '[]')
                || (class_exists($type) && is_a(Traversable::class, $type, true));
        });

        return $noSubTypes ? $types : $this->removeImpossibleArraySubtypes($types, $value);
    }
1062600
public function delete($value)
    {
        foreach (array_keys($this->collection, $value, true) as $key) {
            unset($this->collection[$key]);
        }

        return $this;
    }
1230719
protected function convertValueToSyncFormat($value)
    {
        if (null === $value) {
            return [];
        }

        $orderColumn = $this->getPivotOrderColumn();

        return array_map(
            function ($position) use ($orderColumn) {
                return [ $orderColumn => $position ];
            },
            $value
        );
    }
282816
public function getKey($value) {
		foreach ($this->collection as $k => $v) {
			if ($v === $value) {
				return $k;
			}
		}
		
		return null;
	}
415449
private function convertArrayToArrayValue(array $value)
    {
        $values = [];
        foreach ($value as $val) {
            // ListValues may not contain nested ListValues.
            // Therefore, if an empty array is provided as part of an array,
            // we can encode it as an EntityValue.
            if (is_array($val) && empty($val)) {
                $val = (object) $val;
            }

            $values[] = $this->valueObject($val);
        }

        return [
            'arrayValue' => [
                'values' => $values
            ]
        ];
    }