register a app service
@param string $name the service name
@param mixed $service service
@param bool $replace replace exists service
@return static
966764
public function register($name, $service, $replace = false)
    {
        $this->set($name, $service, $replace);

        return $this;
    }
1125126
public function replace(self $find, self $replace){
		return new static(\str_replace($find, $replace, $this->_Value), $this->_Encoding);
	}
370355
public function generic(string $string, $replace = null, $http_response_code = null)
    {
        $header = new Header($string);

        if (isset($replace)) {
            $header->setReplace($replace);
        }

        if (isset($http_response_code)) {
            $header->setHttpResponseCode($http_response_code);
        }

        $this->addHeader($header);
    }
348080
public static function putHeader($name, $value, $replace = true)
    {
        if (self::$dispatchedHeaders || App::state() > 2) {
            header($name . ': ' . ltrim($value), $replace);
        } else {
            self::$headers[] = array($name, $value, $replace);
        }
    }
1027535
public function saveWorkflow($name, WorkflowDescriptor $descriptor, $replace = false)
    {
        $this->factory->saveWorkflow($name, $descriptor, $replace);
    }
586448
public function setService($name, $service)
    {
        $this->validate($service);
        parent::setService($name, $service);
    }
495910
public function set_header($name, $value, $replace = true)
	{
		if ($replace)
		{
			$this->headers[$name] = $value;
		}
		else
		{
			$this->headers[] = array($name, $value);
		}

		return $this;
	}
1302202
public function unregisterService($name)
    {
        $name = strtolower($name);

        if (isset($this->services->$name)) {
            unset($this->services->$name);
            return true;
        }
        return false;
    }
264569
public static function replace($string, $replace = '***', $santize = false, $dict = '', $attr = null) {
        if ($santize) {
            $string = self::santize($string);
        }
        $keys = self::keywords($string, 500, $dict, $attr);
        if ($keys) {
            foreach ($keys as $key) {
                $string = str_replace($key, $replace, $string);
            }
        }

        return $string;
    }
1160150
public static function replaceAssoc(array $replace, string $subject){
        return str_replace(array_keys($replace), array_values($replace), $subject);
    }
84172
public function convertCallback($name)
    {
        if (preg_match(static::SERVICE_PATTERN, $name)) {
            list($service, $method) = explode(':', $name, 2);
            $callback = array($this->app[$service], $method);
        } else {
            $service = $name;
            $callback = $this->app[$name];
        }

        if (!is_callable($callback)) {
            throw new \InvalidArgumentException(sprintf('Service "%s" is not callable.', $service));
        }

        return $callback;
    }
924551
protected function service($name) {

		if(false === is_string($name)) {
			return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($name)), E_USER_ERROR);
		}

		if(true === ServiceContainer :: has($name)) {
			return ServiceContainer :: get($name);
		}

		$function = Application :: get(['services', $name], false);

		if('object' === gettype($function)) {
			
			$func = $function();

			ServiceContainer :: add($name, $func);
			return $func;
		}

		return trigger_error(sprintf('Argument 1 "%s" passed to %s() is not a known service', $name, __METHOD__), E_USER_ERROR);
	}
1099536
protected function registerService($name, $service)
    {
        $name = strtolower($name);

        if (!isset($this->services->$name)) {
            $this->services->$name = $service;
            return true;
        }
        return false;
    }
1123632
private function service($name)
    {
        if (!isset($this->registry[$name])) {
            if (isset(self::$services[$name])) {
                $this->registry[$name] = new self::$services[$name]($this);
            } else {
                throw new InvalidArgumentException(sprintf('Service %s does not implement', $name));
            }
        }

        return $this->registry[$name];
    }
751602
public function setName(string $name) : Application
    {
        $service = $this->getService();
        $service->setName($name);
        $this->name = $service->getName();
        return $this;
    }
1082756
public function purge($name)
    {
        try {
            if ($service = $this->getService($name)) {
                if ($service instanceof CacheInterface) {
                    $service->flush();
                }
            }
        } catch (\Exception $ex) {
            // could be due to purge triggered by ServiceDeleted event
        }
        unset($this->services[$name]);
        \Cache::forget('service_mgr:' . $name);
        \Cache::forget('service_mgr:id_name_map_active');
        \Cache::forget('service_mgr:id_name_map');
        \Cache::forget('service_mgr:name_type_map_active');
        \Cache::forget('service_mgr:name_type_map');
    }
871203
protected function replaceNamespace(&$stub, $name)
	{
		$stub = str_replace(
			'{{namespace}}', $this->getNamespace($name), $stub
		);

		$stub = str_replace(
			'{{rootNamespace}}', $this->getAppNamespace(), $stub
		);

		return $this;
	}