@param string $name
@param string $device

@return string
423244
protected function replaceTemplateExtension($name, $device)
    {
        if (strstr($name, 'twig')) {
            return str_replace('html.twig', $device . '.html.twig', $name);
        }
        if (strstr($name, 'smarty')) {
            return str_replace('html.smarty', $device . '.html.smarty', $name);
        }

        return $name;
    }
651730
private static function removeContainerFromName($container, $name)
    {
        $name = static::asLocalPath($name);

        if (empty($container)) {
            return $name;
        }
        $container = FileUtilities::fixFolderPath($container);

        return substr($name, strlen($container) + 1);
    }
891628
public function getProvider($name, $request)
    {
        $class = isset($this->providers[$name]) ? $this->providers[$name] : null;

        if (!$class) {
            return null;
        }

        return new $class($request, $request->input('client_id'), $request->input('client_secret'), $request->input('redirect_url'));
    }
898133
public static function getIdentifier(string $name) : string
    {
        return str_replace(
            '.',
            '',
            uniqid(
                preg_match(static::VALID_IDENTIFIER_FORMAT, $name)
                ? $name
                : static::DEFAULT_IDENTIFIER,
                true
            )
        );
    }
642851
public function getEventScript($name)
    {
        $cacheKey = Cache::EVENT_SCRIPT_CACHE_PREFIX . $name;
        try {
            /** @var EventScript $model */
            $model = \Cache::rememberForever($cacheKey, function () use ($name) {
                if ($model = EventScript::whereName($name)->whereIsActive(true)->first()) {
                    if (!empty($model->storage_service_id) && !empty($model->storage_path)) {
                        try {
                            $serviceId = $model->storage_service_id;
                            $service = \ServiceManager::getServiceById($serviceId);
                            $storagePath = trim($model->storage_path, '/');
                            $scmRepo = $model->scm_repository;
                            $scmRef = $model->scm_reference;
                            if (empty($scmRef)) {
                                $scmRef = null;
                            }
                            $serviceName = $service->getName();
                            $typeGroup = $service->getServiceTypeInfo()->getGroup();

                            if ($typeGroup === ServiceTypeGroups::SCM) {
                                $result = \ServiceManager::handleRequest(
                                    $serviceName,
                                    Verbs::GET,
                                    '_repo/' . $scmRepo,
                                    ['path' => $storagePath, 'branch' => $scmRef, 'content' => 1]
                                );
                                $model->content = $result->getContent();
                            } else {
                                $result = \ServiceManager::handleRequest(
                                    $serviceName,
                                    Verbs::GET,
                                    $storagePath,
                                    ['include_properties' => 1, 'content' => 1]
                                );

                                $model->content = base64_decode(array_get($result->getContent(), 'content'));
                            }
                        } catch (\Exception $e) {
                            \Log::error('Failed to fetch remote script. ' . $e->getMessage());
                            throw $e;
                        }
                    }

                    return $model;
                }

                return ''; // so that we don't hit the database even after we know it isn't there
            });

            if (!empty($model)) { // see '' returned above
                return $model;
            }
        } catch (\Exception $ex) {
            \Log::error('Error occurred while loading event script. ' . $ex->getMessage());
        }

        return null;
    }
967871
public function getIdResourceByName(string $name): string
    {
        if (isset($this->resource[$name])) {
            return (string) $this->resource[$name]['id'];
        }
        return '';
    }
745994
protected static function _parseScope($name, $request) {
		$url = trim($request->url, '/');
		$url = $url ? '/' . $url . '/' : '/';

		if (!$config = static::attached($name)) {
			return $url;
		}

		$scheme = $request->scheme . ($request->scheme ? '://' : '//');
		$host = $request->host;

		if ($config['absolute']) {
			preg_match($config['pattern'], $scheme . $host . $url, $match);
		} else {
			preg_match($config['pattern'], $url, $match);
		}

		if ($match) {
			$result = array_intersect_key($match, array_flip($config['params']));
			$request->params = [];
			if (isset($config['library'])) {
				$request->params['library'] = $config['library'];
			}
			$request->params += $result;
			if ($config['prefix']) {
				$url = preg_replace('@^/' . trim($config['prefix'], '/') . '@', '', $url);
			}
			return $url;
		}
		return false;
	}
415899
public function className(string $element, string $name): string
    {
        list($namespace, $name) = $this->parseName($name);

        return Inflector::classify($name) . $this->elementPostfix($element);
    }
29380
public function getParameter(string $name, bool &$contained = NULL) {
        if(isset($this->parameters[$name])) {
            $contained = true;
            return $this->parameters[$name];
        }
        $contained = false;
        return NULL;
    }
420132
public function post(string $name): string {
        if (!isset($this->post[$name])) {
            return "";
        }
        return $this->post[$name];
    }
826968
public function cookie(string $name): string {
        if (!isset($this->cookies[$name])) {
            return "";
        }
        return $this->cookies[$name];
    }
757861
protected function build($name, $storage)
    {
        if ($storage !== null)
        {
            $method = 'build' . ucfirst($name);

            if (method_exists($this, $method))
            {
                return $this->{$method}($storage);
            }

            if (is_array($storage))
            {
                $result = [];
                foreach ($storage as $key => $value)
                {
                    $quote = true;
                    $this->buildRAW($value, $quote);

                    if ($quote)
                    {
                        $value = $this->builder->adapter()->quote($value);
                    }

                    $result[] = $value .
                        (!is_int($key) && $this->alias ?
                            ' AS ' . $this->builder->adapter()->quote($key)
                            : ''
                        );
                }

                return implode(', ', $result);
            }
        }

        return $storage;
    }
14982
public function render($name, array $parameters = array())
    {
        $device = $this->requestStack->getMasterRequest()->get($this->deviceTypeField);

        if (!is_null($device) && '' !== $device) {
            $name = $this->getTemplate($name, $device);
        }

        return parent::render($name, $parameters);
    }
468334
public function create($device, array $tagNames = array()){
        if (!empty($tagNames)){
            $tagEndpoint = new Tags($this->client);
            $tags = $tagEndpoint->findAll($tagNames);
            if(!empty($tags['notFound'])){
                foreach($tags['notFound'] as $name){
                    $tags['tags'][] = $tagEndpoint->create($name);
                }
            }

            $formattedTags = $tagEndpoint->format($tags['tags'], 'other');
            $device['tags'] = $formattedTags['tags'];
        }

        $device = $this->makeJsonReady($device);
        return $this->post('inventory/devices/', $device);
    }
233717
public function classFilename(string $element, string $name): string
    {
        $namespace = $this->classNamespace($element, $name);
        $namespace = substr($namespace, strlen($this->baseNamespace()));

        $directory = $this->baseDirectory() . '/' . str_replace('\\', '/', $namespace);

        return rtrim($directory, '/') . '/' . $this->className($element, $name) . '.php';
    }
140203
public static function getPutParameter(string $name, string $default = null, array $allowed = null): string
    {
        return self::get('PUT', $name, $default, $allowed);
    }
1173822
public function get(string $name) : string
    {
        $result = $this->configCommand($name);

        return $result->getBufferedOutput()[0];
    }