@param resource $socket

@return array
357326
private function parseResponse($socket)
    {
        $headers = '';
        $body = '';
        $processHeaders = true;

        while (!feof($socket) && !$this->detectTimeout($socket)) {
            $line = fgets($socket);

            if ($line === "\r\n") {
                $processHeaders = false;
            } elseif ($processHeaders) {
                $headers .= $line;
            } else {
                $body .= $line;
            }
        }

        return [$headers, $body];
    }
1282316
protected function getWebsocketConnections(): array
    {
        return array_filter(iterator_to_array($this->server->connections), function ($fd) {
            return $this->isServerWebsocket($fd);
        });
    }
557505
public static function getMappings($resource, $key = 'default')
	{
		$resourceName = $resource;

		if( is_object($resource) )
		{
			$resourceName = get_class($resource);
		}

		$mappings = [];
		if( isset(self::$mappers[$key]) )
		{
			$mappings = array_merge_recursive( $mappings, call_user_func(self::$mappers[$key], $resourceName) );
		}

		if( isset(self::$mappings[$key]) && isset(self::$mappings[$key][$resourceName]) )
		{
			$mappings = array_merge_recursive( $mappings, (array) self::$mappings[$key][$resourceName] );
		}

		return $mappings;
	}
517891
public function getResourcePermissions(ResourceInterface $resource) : array
    {
        $query = $this->getRepository()->createQueryBuilder('r')
            ->select('r')
            ->where('r.resource_class = :resourceClass AND r.resource_id=:resourceId')
            ->setParameter('resourceClass', $resource->getClass())
            ->setParameter('resourceId', $resource->getId())
            ->getQuery();

        return $query->getResult();
    }
772481
public function serialize(ResourceType $resourceType)
    {
        return [
            'id' => $resourceType->getId(),
            'name' => $resourceType->getName(),
            'class' => $resourceType->getClass(),
            'tags' => $resourceType->getTags(),
            'enabled' => $resourceType->isEnabled(),
            'actions' => array_map(function (MenuAction $resourceAction) {
                return [
                    'name' => $resourceAction->getName(),
                    'group' => $resourceAction->getGroup(),
                    'scope' => $resourceAction->getScope(),
                    'permission' => $resourceAction->getDecoder(),
                    'default' => $resourceAction->isDefault(),
                ];
            }, $this->actionManager->all($resourceType)),
        ];
    }
670062
public function toArray($request)
    {
        if (is_null($this->resource)) {
            return [];
        }

        return is_array($this->resource)
            ? $this->resource
            : $this->resource->toArray();
    }
79723
private function fetchPrefix(): array
    {
        $prefixLength = socket_recv($this->socket, $prefixBody, 17, MSG_WAITALL);
        if ($prefixBody === false || $prefixLength !== 17) {
            throw new PrefixException(sprintf(
                "unable to read prefix from socket: %s",
                socket_strerror(socket_last_error($this->socket))
            ));
        }

        $result = unpack("Cflags/Psize/Jrevs", $prefixBody);
        if (!is_array($result)) {
            throw new Exceptions\PrefixException("invalid prefix");
        }

        if ($result['size'] != $result['revs']) {
            throw new Exceptions\PrefixException("invalid prefix (checksum)");
        }

        return $result;
    }
375257
public function getUserAuthenticationConfiguration($email, $password) 
    {
        return [
        'grant_type'    => 'password',
        'client_id'     => $this->getClientId(),
        'client_secret' => $this->getClientSecret(),
        'username'      => $email,
        'password'      => $password,
        'scope'         => $this->getScopes(),
        ];
    }
660635
public function checkSocket($socket)
    {
        $read = [$socket];
        // loop through the sockets
        if (count($this->client) > 0) {
            for ($i = 0; $i < $this->max_clients; $i++) {
                if (isset($this->client[$i]) && $this->client[$i]['sock'] != null) {
                    $read[$i + 1] = $this->client[$i]['sock'];
                }
            }
        }

        return $read;
    }
425811
public function search(string $string, string $resources = ''): array
    {
        $query = $this->getRepository('Search')
            ->query()
            ->setParameter('query', $string);
        if ($resources) {
            $query->setParameter('resources', \mb_strtolower($resources));
        }

        return $query->find();
    }
1284234
private function getEvent(Holiday $holiday)
    {
        return [
            'name' => $holiday->getName(),
            'translatedName' => $this->translator->translateName($holiday),
            'timestamp' => $holiday->getTimestamp(),
            'formattedDate' => $holiday->getFormattedDate('Ymd\THis\ZO'),
            'type' => $holiday->getType(),
            'formattedType' => $this->getTypeNames($this->getTypeList($holiday->getType())),
        ];
    }
86547
static public function getFromSocket($socket) {
        try {
            $version = $socket->getVersion();
        } catch (Mage_Core_Exception $e) {
            Mage::getSingleton('core/session')
                ->addError('Error determining Varnish version: '.
                    $e->getMessage());
            return null;
        }
        switch ($version) {
            case '4.0':
            case '4.1':
                return Mage::getModel(
                    'turpentine/varnish_configurator_version4',
                    array('socket' => $socket) );

            case '3.0':
                return Mage::getModel(
                    'turpentine/varnish_configurator_version3',
                        array('socket' => $socket) );
            case '2.1':
                return Mage::getModel(
                    'turpentine/varnish_configurator_version2',
                        array('socket' => $socket) );
            default:
                Mage::throwException('Unsupported Varnish version');
        }
    }
892420
public function serialize(ResourceRights $resourceRights)
    {
        return [
            'id' => $resourceRights->getUuid(),
            'mask' => $resourceRights->getMask(),
            'resource' => [
                'id' => $resourceRights->getResource()->getUuid(),
            ],
            'role' => $this->roleSerializer->serialize($resourceRights->getRole()),
        ];
    }
816065
private function serializeToArray($resource): array
    {
        $manager = new Manager();
        $manager->setSerializer(new DataArraySerializer());

        $transformation = $manager->createData($resource)->toArray();

        return $transformation['data'];
    }
92338
private function exportResource(AbstractResource $resource, $locale)
    {
        $resources = [];

        $event = $this->dispatchEvent($resource, $locale);
        $embedResources = $event->getEmbedResources();

        // Grab data from event
        $resources[$resource->getResourceNode()->getId()] = [
            'node' => $resource->getResourceNode(),
            'template' => $event->getTemplate(),
            'assets' => $event->getAssets(),
            'files' => $event->getFiles(),
            'translation_domains' => $event->getTranslationDomains(),
            'resources' => array_keys($embedResources), // We only need IDs
        ];

        if (!empty($embedResources)) {
            foreach ($embedResources as $embedResource) {
                if (empty($resources[$embedResource->getResourceNode()->getId()])) {
                    // Current resource has not been exported yet
                    $exported = $this->exportResource($embedResource, $locale);
                    $resources = array_merge($resources, $exported);
                }
            }
        }

        return $resources;
    }
1196608
private function getResourceSerializerGroups(string $resourceClass): array
    {
        $serializerClassMetadata = $this->serializerClassMetadataFactory->getMetadataFor($resourceClass);

        $groups = [];
        foreach ($serializerClassMetadata->getAttributesMetadata() as $serializerAttributeMetadata) {
            $groups += array_flip($serializerAttributeMetadata->getGroups());
        }

        return array_keys($groups);
    }
591986
protected function prepareHeaders($server)
    {
        $output = [];

        if (!is_array($server)) {
            return $output;
        }

        foreach ($server as $key => $value) {
            if (is_string($key) && strlen($key) > 5 && strpos($key, 'HTTP_') !== false) {
                $output[substr($key, 5)] = $value;
            }
        }

        return $output;
    }