Returns an object of Google Analytics service response
@param array $settings
@param array $handler
@return \Google_Service_AnalyticsReporting_GetReportsResponse
@throws OutOfRangeException
4122
public function request(array $settings, array $handler)
    {
        if (empty($settings['ga_profile_id'])) {
            throw new OutOfRangeException('Google Analytics profile ID is empty in the request settings');
        }

        $service = $this->getService($settings); // Also loads all needed libraries

        $request = new \Google_Service_AnalyticsReporting_ReportRequest;
        $request->setViewId($settings['ga_profile_id']);

        $this->setRequestDate($request, $handler);
        $this->setRequestMetrics($request, $handler);
        $this->setRequestSorting($request, $handler);
        $this->setRequestDimensions($request, $handler);

        $body = new \Google_Service_AnalyticsReporting_GetReportsRequest;
        $body->setReportRequests(array($request));

        return $service->reports->batchGet($body);
    }
553203
private function _returnError(Settings $settings, Entry $entry)
    {
        if ($this->hasEventHandlers(self::EVENT_AFTER_ERROR)) {
            $this->trigger(self::EVENT_AFTER_ERROR, new SaveEvent([
                'entry' => $entry
            ]));
        }

        if (Craft::$app->getRequest()->getAcceptsJson()) {
            return $this->asJson([
                'success' => false,
                'errors' => $entry->getErrors(),
            ]);
        }

        Craft::$app->getSession()->setError(Craft::t('guest-entries', 'Couldn’t save entry.'));

        // Send the entry back to the template
        Craft::$app->getUrlManager()->setRouteParams([
            'variables' => [$settings->entryVariable => $entry]
        ]);

        return null;
    }
658627
public function getSymfonyResponse($settings = null)
    {
        $headers = static::getCORSResponseHeaders();

        if (static::isOptionsRequest()) {
            return new \Symfony\Component\HttpFoundation\Response('', 200, $headers);
        }

        if (!$settings) {
            $settings = $this->getSettings();
        }
        $data = $this->getResponseObject($settings);

        $data['remote'] = [
            'url' => $settings->getFetchUrl(),
            'refreshAfter' => $this->refreshAfter
        ];
        $data['remote'][$settings->getFetchUrl()] = $data['settings']['main'];

        $response = new \Symfony\Component\HttpFoundation\JsonResponse($data, 200, $headers);

        if (($callback = $this->getCallback())) {
            $response->setCallback($callback);
        }

        return $response;
    }
1082856
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        //Only GET methods are allowed
        if ($request->getMethod() !== 'GET') {
            if ($this->continueOnError) {
                return $handler->handle($request);
            }

            return $this->createResponse(405)->withHeader('Allow', 'GET');
        }

        $file = static::getFilename($request->getUri()->getPath());

        if ($this->filesystem->has($file)) {
            return $this->read($request, $file);
        }

        //If the file does not exists, check if is gzipped
        $file .= '.gz';

        if (stripos($request->getHeaderLine('Accept-Encoding'), 'gzip') === false || !$this->filesystem->has($file)) {
            if ($this->continueOnError) {
                return $handler->handle($request);
            }

            return $this->createResponse(404);
        }

        return $this->read($request, $file)->withHeader('Content-Encoding', 'gzip');
    }
332683
public static function relative($handler, array $params = [])
    {
        return substr(app()->request->base_url, 0, -1).app()->router->generate($handler, $params);
    }
1315964
public function get(string $uriPath, callable $handler, array $parameters = []): GroupInterface
    {
        return $this->method('GET', $uriPath, $handler, $parameters);
    }
240825
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
	{
		[
			'Request-Type' => $type,
			'Response-Headers' => $headers,
		] = $this->analyze($request);

		switch ($type) {
			case self::ERROR_NO_HOST_HEADER:
			case self::ERROR_ORIGIN_NOT_ALLOWED:
			case self::ERROR_METHOD_NOT_SUPPORTED:
			case self::ERROR_HEADERS_NOT_SUPPORTED:
				return Factory::response(403);

			case self::TYPE_REQUEST_OUT_OF_CORS_SCOPE:
				return $handler->handle($request);

			case self::TYPE_PRE_FLIGHT_REQUEST:
				$response = Factory::response(200);

				return self::withCorsHeaders($response, $headers);

			default:
				$response = $handler->handle($request);

				return self::withCorsHeaders($response, $headers);
		}
	}
773309
public function settings(array $settings = null)
    {
        if ($settings !== null) {
            $this->settings = $settings;
        }

        return $this->settings;
    }
561972
public static function select( $table, $fields = array(), $handler = null )
	{
		return Query_Select::create( $table, $handler )->fields( $fields );
	}
901790
public function checkSPSettings($settings)
    {
        assert('is_array($settings)');

        if (!is_array($settings) || empty($settings)) {
            return array('invalid_syntax');
        }

        $errors = array();

        if (!isset($settings['sp']) || empty($settings['sp'])) {
            $errors[] = 'sp_not_found';
        } else {
            $sp = $settings['sp'];
            $security = array();
            if (isset($settings['security'])) {
                $security = $settings['security'];
            }

            if (!isset($sp['entityId']) || empty($sp['entityId'])) {
                $errors[] = 'sp_entityId_not_found';
            }

            if (!isset($sp['assertionConsumerService'])
                || !isset($sp['assertionConsumerService']['url'])
                || empty($sp['assertionConsumerService']['url'])
            ) {
                $errors[] = 'sp_acs_not_found';
            } else if (!filter_var($sp['assertionConsumerService']['url'], FILTER_VALIDATE_URL)) {
                $errors[] = 'sp_acs_url_invalid';
            }

            if (isset($sp['singleLogoutService'])
                && isset($sp['singleLogoutService']['url'])
                && !filter_var($sp['singleLogoutService']['url'], FILTER_VALIDATE_URL)
            ) {
                $errors[] = 'sp_sls_url_invalid';
            }

            if (isset($security['signMetadata']) && is_array($security['signMetadata']) &&
                (!isset($security['signMetadata']['keyFileName']) || !isset($security['signMetadata']['certFileName']))) {
                $errors[] = 'sp_signMetadata_invalid';
            }

            if (((isset($security['authnRequestsSigned']) && $security['authnRequestsSigned'] == true)
                || (isset($security['logoutRequestSigned']) && $security['logoutRequestSigned'] == true)
                || (isset($security['logoutResponseSigned']) && $security['logoutResponseSigned'] == true)
                || (isset($security['wantAssertionsEncrypted']) && $security['wantAssertionsEncrypted'] == true)
                || (isset($security['wantNameIdEncrypted']) && $security['wantNameIdEncrypted'] == true))
                && !$this->checkSPCerts()
            ) {
                $errors[] = 'sp_certs_not_found_and_required';
            }
        }

        if (isset($settings['contactPerson'])) {
            $types = array_keys($settings['contactPerson']);
            $validTypes = array('technical', 'support', 'administrative', 'billing', 'other');
            foreach ($types as $type) {
                if (!in_array($type, $validTypes)) {
                    $errors[] = 'contact_type_invalid';
                    break;
                }
            }

            foreach ($settings['contactPerson'] as $type => $contact) {
                if (!isset($contact['givenName']) || empty($contact['givenName'])
                    || !isset($contact['emailAddress']) || empty($contact['emailAddress'])
                ) {
                    $errors[] = 'contact_not_enought_data';
                    break;
                }
            }
        }

        if (isset($settings['organization'])) {
            foreach ($settings['organization'] as $organization) {
                if (!isset($organization['name']) || empty($organization['name'])
                    || !isset($organization['displayname']) || empty($organization['displayname'])
                    || !isset($organization['url']) || empty($organization['url'])
                ) {
                    $errors[] = 'organization_not_enought_data';
                    break;
                }
            }
        }

        return $errors;
    }
40424
protected static function createHandler(array $settings): HandlerInterface
    {
        assert(array_key_exists(C::KEY_LOG_PATH, $settings) === true);

        $logPath  = $settings[C::KEY_LOG_PATH];
        $logLevel = $settings[C::KEY_LOG_LEVEL] ?? Logger::ERROR;
        $handler  = new StreamHandler($logPath, $logLevel);
        $handler->setFormatter(new LineFormatter(null, null, true, true));
        $handler->pushProcessor(new WebProcessor());
        $handler->pushProcessor(new UidProcessor());

        return $handler;
    }
248554
protected function getHandlerAdapter($handler)
    {
        foreach ($this->handlerAdapters as $ha) {
            if ($ha->supports($handler)) {
                return $ha;
            }
        }
        throw new \Exception("No adapter for handler [".get_class($handler)."]: The DispatcherServlet configuration needs to include a HandlerAdapter that supports this handler.");
    }
1056630
public static function get( array $settings = [] ){
		$class_name = get_called_class();
		if( !isset(self::$instances[$class_name]) ){
			self::$instances[$class_name] = new $class_name($settings);
		}
		return self::$instances[$class_name];
	}
508316
public function hookDashboardHandlers(array &$handlers)
    {
        $weight = count($handlers);
        $model = $this->getModel();
        $settings = $this->module->getSettings('ga_report');

        foreach ($model->getHandlers() as $id => $handler) {

            if (!in_array($id, $settings['dashboard'])) {
                continue;
            }

            $weight++;

            $report = $model->get($handler, $settings);

            $handlers["ga_$id"] = array(
                'status' => true,
                'weight' => $weight,
                'title' => $handler['name'],
                'template' => $handler['template'],
                'handlers' => array(
                    'data' => function () use ($handler, $report, $settings) {
                        return array(
                            'report' => $report,
                            'handler' => $handler,
                            'settings' => $settings
                        );
                    }
                )
            );
        }
    }
1259764
public function get(array $metrics = [], ?int $since = null, ?int $until = null): InsightsResponse
    {
        $metrics = $this->isValidMetrics($metrics);

        $request = new InsightsRequest($this->pageToken, $metrics, $since, $until);
        $response = $this->client->get('me/insights', $request->build());

        return new InsightsResponse($response);
    }
55014
public static function get($route, $handler, $options = [])
    {
        app()->router->get($route, $handler, $options);
    }
338564
final public function offsetGet($offset)
    {
        if (!isset($this->props['items'][$offset])) {
            throw new OutOfRangeException('Trace['.$offset.'] is not found');
        }
        return $this->props['items'][$offset];
    }