Find Internal Client

In separate function so we can call it multiple times.

@return  array  Client detials
551679
private function findInternalClient()
	{
		// create model and fetch applications matching fitlers
		$application = \Components\Developer\Models\Application::all()
			->whereEquals('hub_account', 1)
			->row();

		// make sure we have at least one 
		// although it should always only be one
		if (!$application->get('id'))
		{
			return false;
		}

		// return first as an array
		return $application->toArray();
	}
904536
private function _getClient(): ClientInterface
    {
        if (! $this->client instanceof ClientInterface) $this->client = new Client($this->clientConfig);
        return $this->client;
    }
1205274
public function getClientIp()
    {
        if (!empty($this->getHeader('X-Forwarded-For'))) {
            $ip = preg_replace('/(?:,.*)/', '', $this->hasHeader('X-Forwarded-For'));
        } elseif (!empty($this->getHeader('Client-Ip'))) {
            $ip = $this->getHeader('Client-Ip');
        } else {
            $ip = $_SERVER['REMOTE_ADDR'];
        }
        return trim($ip);
    }
1369936
public function getCurrent()
    {
        $data = [];
        foreach (get_object_vars($this) as $key => $value) {
            if (substr($key, 0, 8) !== 'internal') {
                $data[$key] = $value;
            }
        }

        return $data;
    }
743117
protected function getClient() {
		if(!$this->client) {
			$this->client = new Client([
				RequestOptions::VERIFY  => self::$VERIFY_SSL,
				RequestOptions::TIMEOUT => $this->timeout,
			]);
		}
		return $this->client;
	}
591017
public static function caller ( )
	{
		$backtrace = V(debug_backtrace());

		foreach ($backtrace as $line) {
			$line = A($line);

			if ($line->class === 'Bacon\Log') continue;

			return A([
				'class'  => $line->class,
				'file'   => $line->file,
				'method' => $line->function,
				'object' => $line->object
			]);
		}

		/*
		if (isset($backtrace[2]['class'])) {
			return $backtrace[2]['class'];
		} elseif (isset($backtrace[2]['file'])) {
			return $backtrace[2]['file'];
		} else {
			return $backtrace[0]['file'];
		}
		 */
	}
355771
public function getClient()
    {
        if (!$this->client instanceof Client) {
            $this->client = new Client([
                "cookies" => true
            ]);
        }
        return $this->client;
    }
1278637
protected function getClient() {
        if ($this->client === null) {
            $this->client = new Client($this->getParam('accountId'), $this->getParam('applicationKey'));
        }

        return $this->client;
    }
626579
public function getBestFromClient() {
		// get all language keys from client
		$client_langs = $this->getFromClient();

		foreach ($client_langs as $client_lang) {
			foreach ($this->_possible as $possible) {
				$l10n = $this->getL10n($possible);

				if (in_array($client_lang, $l10n['keys'])) {
					return $client_lang;
				}
			}
		}
	}
1178942
protected function getGuzzleClient()
    {
        $options = [];

        // Check if the client must use a proxy server.
        if (!empty($_SERVER['HTTP_PROXY']) || !empty($_SERVER['http_proxy'])) {
            $proxy = !empty($_SERVER['http_proxy']) ? $_SERVER['http_proxy'] : $_SERVER['HTTP_PROXY'];
            $options['proxy'] = $proxy;
        }

        return new Client($options);
    }
1241851
protected function getClient()
	{
		$this->client->timeout       = $this->timeout;
		$this->client->sslVerifyPeer = $this->sslVerifyPeer;

		return $this->client;
	}
940663
protected function getFds()
    {
        $fds = array_filter($this->to, function ($value) {
            return is_integer($value);
        });
        $rooms = array_diff($this->to, $fds);

        foreach ($rooms as $room) {
            $clients = $this->room->getClients($room);
            // fallback fd with wrong type back to fds array
            if (empty($clients) && is_numeric($room)) {
                $fds[] = $room;
            } else {
                $fds = array_merge($fds, $clients);
            }
        }

        return array_values(array_unique($fds));
    }
32172
public static function getCurrentIP()
    {
        $ip = '';

        foreach (['HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR'] as $headerKey) {
            if ($item = getenv($headerKey)) {
                foreach (array_filter(explode(',', $item), 'trim') as $ipAddress) {
                    if ($ip = filter_var($ipAddress, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE)) {
                        break 2;
                    }
                }
            }
        }

        return (string) $ip;
    }
987992
protected function getClientUserAgent()
    {
        if ($this->requestStack->getCurrentRequest() === null) {
            throw new \RuntimeException(sprintf('%s can not be called outside of request cycle', __METHOD__));
        }

        return $this->requestStack->getCurrentRequest()->server->get('HTTP_USER_AGENT');
    }
771806
public static function getClientIp()
    {
        //Just get the headers if we can or else use the SERVER global
        if (function_exists('apache_request_headers')) {
            $headers = apache_request_headers();
        } else {
            $headers = $_SERVER;
        }
        //Get the forwarded IP if it exists
        if (array_key_exists('X-Forwarded-For', $headers) &&
            filter_var($headers['X-Forwarded-For'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
            $the_ip = $headers['X-Forwarded-For'];
        } else {
            if (array_key_exists('HTTP_X_FORWARDED_FOR', $headers) &&
                filter_var($headers['HTTP_X_FORWARDED_FOR'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
                $the_ip = $headers['HTTP_X_FORWARDED_FOR'];
            } else {
                if (array_key_exists('X-ClientSide', $headers)) {
                    $parts  = explode(':', $headers['X-ClientSide']);
                    $the_ip = $parts[0];
                } else {
                    $the_ip = filter_var($_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4);
                }
            }
        }
        return $the_ip;
    }
1152999
public function index(): array
    {
        /** @var Client[] $clients */
        $clients = parent::index();
        foreach ($clients as $client) {
            $this->addScopeAndRedirectUris($client);
        }

        return $clients;
    }
16020
public static function getAppliedFilters()
    {
        $classMethods = get_class_methods(get_class());
        $calledClassMethods = get_class_methods(get_called_class());

        $filteredMethods = array_filter(
            $calledClassMethods, function ($calledClassMethod) use ($classMethods) {
                return !in_array($calledClassMethod, $classMethods, true);
            }
        );

        return \Illuminate\Support\Facades\Request::only($filteredMethods);
    }