Parse the class name and setup the custom exception class of the client
and return the "service" name of the client and "exception_class".

@return array
771047
private function parseClass()
    {
        $klass = get_class($this);

        if ($klass === __CLASS__) {
            return ['', 'Aws\Exception\AwsException'];
        }

        $service = substr($klass, strrpos($klass, '\\') + 1, -6);

        return [
            strtolower($service),
            "Aws\\{$service}\\Exception\\{$service}Exception"
        ];
    }
905390
public function parse()
    {
        $result = new stdClass();
        $cache = $parser = $exception = $cacheKey = $path = null;
        try {
            $path = $this->find(false);
            // Cached response
            $cache = new PathCache(__FUNCTION__, $this->options);
            $cacheKey = $cache->getKey([$path]);
            $result = $cache->readFrom($cacheKey);
            if ($result !== false) {
                return $result;
            }
            // Real response
            $parser = $this->getParser();
            $result = $parser->parse($path);
        } catch (InvalidArgumentException $exception) {
            $this->mergeMessages($exception, __FUNCTION__);
        }
        $this->mergeMessages($parser, __FUNCTION__);
        $this->mergeMessages($cache, __FUNCTION__);

        // Re-throw parser exception
        if ($exception) {
            throw $exception;
        }

        if ($cache && $cacheKey) {
            $cache->writeTo($cacheKey, $result, ['path' => $path]);
        }

        return $result;
    }
200906
protected function parseProxyClassInfo()
    {
        $arr = explode("\\", $this->interface);
        $name = array_pop($arr);
        $matches = array();
        if (!preg_match($this->getClassNameRule(), $name, $matches)) {
            throw new InitiallyRpcException("Proxy builder error: interface name must ending of '{$this->interfaceEndOf}' like 'DemoService{$this->interfaceEndOf}'");
        }

        $replace = $this->config->getReplace();
        $replaceKey = $this->service->getReplaceKey();
        if (!empty($arr) && !empty($replace) && isset($replace[$replaceKey])) {
            foreach ($arr as $key => $value) {
                if (isset($replace[$replaceKey][$value])) {
                    $arr[$key] = $replace[$replaceKey][$value];
                }
            }
        }

        $namespace = implode("\\", $arr);
        $info = new ProxyClassInfo();
        $info->setNamespace($namespace);
        $info->setClassName($matches[1]);

        return $info;
    }
1343989
public function getSystemId()
    {
        if (!is_null($this->_systemId)) {
            return $this->_systemId;
        }
        preg_match('/' . ucfirst($this->moduleType) . '([A-Za-z]+)\\\Module/', get_class($this), $matches);
        if (!isset($matches[1])) {
            throw new Exception(get_class($this) . " is not set up correctly!");
        }

        return $this->_systemId = $matches[1];
    }
352349
public static function getServiceAccountName() {
    $req = new GetServiceAccountNameRequest();
    $resp = new GetServiceAccountNameResponse();

    try {
      ApiProxy::makeSyncCall(self::PACKAGE_NAME, 'GetServiceAccountName', $req,
          $resp);
    } catch (ApplicationError $e) {
      throw self::applicationErrorToException($e);
    }

    return $resp->getServiceAccountName();
  }
502087
private function initClient() {
		if(isset($_COOKIE[self::CLIENT_INFO_COOKIE])) {
			$clientData = @json_decode(base64_decode($_COOKIE[self::CLIENT_INFO_COOKIE], true), true);
			if(!$clientData) {
				throw new \Exception('Wrong format of response cookie data: ' . $_COOKIE[self::CLIENT_INFO_COOKIE]);
			}

			$client = new Client($clientData);
			if(isset($clientData['auth'])) {
				$client->auth = new ClientAuth($clientData['auth']);
			}
			return $client;
		}
	}
586221
public function getName()
    {
        if (!null === $this->name) {
            $errMsg = 'service name not exists';
            throw new Exception\InvalidServiceConfigException($errMsg);
        }
        return $this->name;
    }
58351
public function toArray()
	{
		$list = parent::toArray();

		$list['service.typeid'] = $this->getTypeId();
		$list['service.type'] = $this->getType();
		$list['service.code'] = $this->getCode();
		$list['service.label'] = $this->getLabel();
		$list['service.provider'] = $this->getProvider();
		$list['service.position'] = $this->getPosition();
		$list['service.config'] = $this->getConfig();
		$list['service.status'] = $this->getStatus();

		return $list;
	}
542914
private Class[] parseRecoverableExceptionClassNames(String recoverableExceptionClassNames) {
    if (recoverableExceptionClassNames != null) {
      recoverableExceptionClassNames = recoverableExceptionClassNames.trim();
      if (recoverableExceptionClassNames.length() == 0) {
        recoverableExceptionClassNames = null;
      }
    }
    if (recoverableExceptionClassNames == null) {
      return new Class[0];
    } 
    String[] classNames = recoverableExceptionClassNames.split(",");
    Class[] classes = new Class[classNames.length];
    for (int i = 0; i < classNames.length; i++) {
      try {
        classes[i] = Class.forName(classNames[i].trim());
      } catch (ClassNotFoundException e) {
        throw new RuntimeException(e);
      }
    }
    return classes;
  }
113702
protected function parse()
    {
        $json = $this->httpResponse->json();

        $service = new Service();

        (new ArrayUtils())->callSetters(
            $service,
            $json,
            [
                'autodestroy', 'autorestart', 'bindings', 'container_envvars',
                'container_ports', 'containers', 'cpu_shares',
                'current_num_containers', 'deployed_datetime',
                'deployment_strategy', 'destroyed_datetime', 'entrypoint',
                'image_name', 'image_tag', 'link_variables',
                'linked_from_service', 'memory', 'name', 'privileged',
                'public_dns', 'resource_uri', 'roles', 'run_command',
                'running_num_containers', 'sequential_deployment',
                'started_datetime', 'state', 'stopped_datetime',
                'stopped_num_containers', 'tags', 'target_num_containers',
                'unique_name', 'uuid', 'webhook'
            ]
        );

        $this->service = $service;
    }
947021
public function getDescription()
    {
        return class_basename($this->exception).
            ' line '.$this->exception->getLine().
            ' in '.$this->exception->getFile();
    }
675363
public function getCauseMessage()
    {
        $causes  = [];
        $current = [
            'class'   => get_class($this),
            'message' => $this->getMessage(),
            'code'    => $this->getCode(),
            'file'    => $this->getFile(),
            'line'    => $this->getLine()
        ];

        $causes[] = $current;
        $previous = $this->getPrevious();

        while ($previous !== null) {
            if ($previous instanceof Exception) {
                $prevCauses = $previous->getCauseMessage();

                foreach ($prevCauses as $cause) {
                    $causes[] = $cause;
                }
            } elseif ($previous instanceof PhpException) {
                $causes[] = [
                    'class'   => get_class($previous),
                    'message' => $previous->getMessage(),
                    'code'    => $previous->getCode(),
                    'file'    => $previous->getFile(),
                    'line'    => $previous->getLine()
                ];
            }

            $previous = $previous->getPrevious();
        }

        return $causes;
    }
339945
public function getErrors() {
		if ($this->forbiddenClasses) {
			return $this->forbiddenClasses;
		}
		
		if ($this->useCache) {
			// Cache duration: 30 minutes.
			$this->forbiddenClasses = $this->cacheService->get("forbidden.classes.".__DIR__."/".json_encode($this->selfEdit));
			if ($this->forbiddenClasses != null) {
				return $this->forbiddenClasses;
			}
		}
		
		$this->analyze();
		return $this->forbiddenClasses;
	}
619940
private function parseClass()
    {
        // check which interfaces are implemented
        $interfaces = [];
        foreach ($this->parentClasses as $pc) {
            $interfaces = array_merge($interfaces,
                $pc->getInterfaceNames()); // returns only the interfaces that the current class implements
        }
        $interfaces = array_unique($interfaces);

        foreach ($interfaces as $i) {
            if ($i == AccessInterface::class) {
                $this->parsedClass->accessInterface = true;
            }

            if ($i == CacheKeyInterface::class) {
                $this->parsedClass->cacheKeyInterface = true;
            }
        }
    }
353942
protected function getExceptionName()
    {
        if ($this->exception instanceof Exception) {
            $name = $this->exception->getName();
        } elseif ($this->exception instanceof ErrorException) {
            $name = $this->exception->getName();
        } else {
            $name = $this->defaultName;
        }
        return $name;
    }
347556
public function getParserClass()
    {
        $server = RequestContext::getServer();
        if($server instanceof \Imi\Server\WebSocket\Server)
        {
            return ConnectContext::get('httpRouteResult')['wsConfig']->parserClass ?? JsonObjectParser::class;
        }
        else if($server instanceof \Imi\Server\TcpServer\Server || $server instanceof \Imi\Server\UdpServer\Server)
        {
            return $server->getConfig()['dataParser'] ?? JsonObjectParser::class;
        }
        else
        {
            return JsonObjectParser::class;
        }
    }
305740
public function parse()
    {
        $annotations = ['rest' => []];
        foreach ($this->classes as $c) {
            $classAnnotations = $this->annotationsFromClass($c->getName())->toArray();
            if (isset($classAnnotations['rest'])) {
                $annotations['rest'] = array_merge($classAnnotations['rest'], $annotations['rest']);
            }
        }
        $annotations = new ConfigObject($annotations);

        $this->classDefaults = $annotations->get('rest', new ConfigObject([]));

        // get method annotations
        $annotations = ['rest' => [], 'param' => []];
        foreach ($this->classes as $c) {
            try {
                $methodAnnotations = $this->annotationsFromMethod($c->getName(), $this->method->name)->toArray();
            } catch (\Exception $e) {
                continue;
            }
            if (isset($methodAnnotations['rest']) && is_array($methodAnnotations['rest'])) {
                $annotations['rest'] = array_merge($methodAnnotations['rest'], $annotations['rest']);
            }
            if (isset($methodAnnotations['param'])) {
                if (is_array($methodAnnotations['param'])) {
                    $annotations['param'] = array_merge($methodAnnotations['param'], $annotations['param']);
                } else {
                    $annotations['param'][] = $methodAnnotations['param'];
                }

            }
        }

        $annotations = new ConfigObject($annotations);

        $restAnnotations = $annotations->get('rest', new ConfigObject([]));
        $paramAnnotations = $annotations->get('param', new ConfigObject([]));

        // check if we should ignore this method
        if ($restAnnotations->get('ignore', false) !== false) {
            return false;
        }

        // create ApiMethod instance
        $parsedMethod = new ParsedMethod($this->method->name);

        // method
        $parsedMethod->method = $this->getMethod($restAnnotations);
        // role
        $parsedMethod->role = $this->getRole($restAnnotations);
        // cache.ttl
        $parsedMethod->cache = $this->getCache($restAnnotations);
        // header.cache.expires
        $parsedMethod->header = $this->getHeader($restAnnotations);
        // default
        $parsedMethod->default = $this->getDefault($restAnnotations);
        // rateControl.ignore
        $parsedMethod->rateControl = $this->getRateControl($restAnnotations);

        // parse method parameters
        $parameterParser = new ParameterParser($this->method->getParameters(), $paramAnnotations);
        $parameters = $parameterParser->parse();
        foreach ($parameters as $p) {
            $parsedMethod->addParameter($p);
        }

        // build the url pattern
        if ($restAnnotations->get('url', false)) {
            // build url pattern using the provided rest.url pattern
            $urlPattern = $this->buildUrlPatternFromPattern($restAnnotations->get('url'), $parameters);
            $resourceNaming = true;
        } else {
            // build url pattern using method name and parameters
            $urlPattern = $this->buildUrlPatternStandard($this->method->name, $parameters);
            $resourceNaming = false;
        }

        $parsedMethod->setUrlPattern($urlPattern, $resourceNaming);

        return $parsedMethod;
    }