Extracts a message domain from the translator call.

@param \SplFileInfo $file
@param \Peast\Syntax\Node\Expression[] $arguments

@return string|null
968692
private function extractDomain(SplFileInfo $file, array $arguments): ?string
    {
        if (isset($arguments[self::DOMAIN_ARG])) {
            $domainNode = $arguments[self::DOMAIN_ARG];

            if (!($domainNode instanceof Node\StringLiteral)) {
                $position = $domainNode->getLocation()->getStart();

                $this->logger->error(sprintf(
                    'Could not extract domain, expected string literal but got %s (in %s on line %d column %d).',
                    $domainNode->getType(),
                    $file->getRealPath(),
                    $position->getLine(),
                    $position->getColumn()
                ));
            }

            return $domainNode->getValue();
        }

        return null;
    }
628310
private function getRealCommandName($file)
    {
        $iter = CommandLine\Commands::getInstance();
        $commands = array();
        foreach ($iter as $name => $data) {
            $commands[$name] = $data;
        }
        ksort($commands);

        if (!file_exists($file)) {
            foreach ($commands as $command) {
                if (is_array($command["command"]["aliases"]) && in_array($file, $command["command"]["aliases"])) {
                    return $command["command"]["name"];
                }
            }
        }

        return $file;
    }
299086
public function extractMeaning($file, Context $context = null, array $queryParams = [])
    {
        if (!$file || (!is_resource($file) && !is_readable($file))) {
            throw new \InvalidArgumentException('$file argument must be a readable file path or a valid resource');
        }

        if (null !== $context && !$context->isEmpty()) {
            $queryParams['context'] = json_encode($context);
        }

        $file = is_resource($file) ? $file : fopen($file, 'r');
        $response = $this->client->send('POST', '/speech', $file, $queryParams);

        return $this->decodeResponse($response);
    }
898893
public function getFileContents(\SplFileInfo $file)
    {
        if ($file->getExtension() === 'php') {
            $content = include $file->getPathname();
            return $content;
        }

        $level = error_reporting(0);
        $content = file_get_contents($file->getPathname());
        error_reporting($level);
        if (false === $content) {
            $error = error_get_last();
            throw new \RuntimeException($error['message']);
        }
        return $content;
    }
526871
protected function extractNamespace(
        File $file
    ) {
        $namespace = '';

        $tokens = $file->getTokens();

        $prev = $file->findNext(T_NAMESPACE, 0);

        for ($i = $prev + 2; $i < count($tokens); $i++) {
            if (!in_array($tokens[$i]['code'], [T_STRING, T_NS_SEPARATOR])) {
                break;
            }

            $namespace .= $tokens[$i]['content'];
        }

        return $namespace;
    }
547230
protected function _extractSequence($file)
    {
        $sequence = '';
        $hlpr = Mage::helper('radial_core');
        $domDocument = $hlpr->getNewDomDocument();
        // load feed files to dom object
        $domDocument->load($file);
        $feedXpath = $hlpr->getNewDomXPath($domDocument);
        $correlationId = $feedXpath->query('//MessageHeader/MessageData/CorrelationId');
        if ($correlationId->length) {
            $sequence = (string) $correlationId->item(0)->nodeValue;
        }
        return $sequence;
    }
470931
protected function load(SplFileInfo $file)
    {
        $path = $file->getPathName();

        if (!isset($this->cache['contents'][$path])) {
            $data    = $this->decoder->decode($file->getContents(), static::getFormat($file));
            $context = ['file' => $file, 'data' => $data];

            if (is_array($data)) {
                foreach ($this->handlers as $property => $handler) {
                    if ($handler->isSupported($data)) {
                        $value = isset($data[$property]) ? $data[$property] : null;
                        $data[$property] = $handler->handle($value, $context);
                    }
                }
            }

            $this->cache['contents'][$path] = $data;
        }

        return $this->cache['contents'][$path];
    }
301155
public function getText($file, $callback = null)
    {
        if(!is_null($callback))
        {
            $this->setCallback($callback);
        }

        return $this->request('text', $file);
    }
1071868
protected function getFilePath(SplFileInfo $file)
	{
		$location = $file->getPathname();
		$path = $this->removePathPrefix($location);

		return \trim(\str_replace('\\', '/', $path), '/');
	}
1129569
protected function getFilePieces(\SplFileInfo $file)
    {
        $key = $file->getBasename();
        if (!array_key_exists($key, $this->filePieces)) {
            $pieces = explode('.', $file->getBasename());
            if (count($pieces) < 3) {
                return true;
            }
            $extension = array_pop($pieces);
            $locale = array_pop($pieces);
            $domain = implode('.', $pieces);

            $this->filePieces[$key] = [
                self::FILE_PIECE_DOMAIN => $domain,
                self::FILE_PIECE_LOCALE => $locale,
                self::FILE_PIECE_EXTENSION => $extension,
            ];
        }

        return $this->filePieces[$key];
    }
1122491
protected function translate($key, array $arguments = null)
    {
        $ret = LocalizationUtility::translate($key, $this->extensionName, $arguments);

        // Not translated handling
        if ($ret === null) {
            $ret = '[-' . $key . '-]';
        }

        return $ret;
    }
286568
private function resolve(SplFileInfo $file): Closure
    {
        return function(IServerRequest $request, IResponse $response, callable $next) use ($file)
        {
            return $this->container->call(import($file->getRealPath()),
            [
                'request' => $request,
                'response' => $response,
                'next' => $next,
                'config' => $this->config
            ]);
        };
    }
1044330
private function extractDesc(array $arguments): ?string
    {
        if (!empty($arguments)) {
            foreach ($arguments[self::ID_ARG]->getLeadingComments() as $comment) {
                $annotations = $this->docParser->parse($comment->getText());
                if (!empty($annotations)) {
                    return $annotations[0]->text;
                }
            }
        }

        return null;
    }
1339081
public static function extractFromFile($file)
    {
        $contents = file_get_contents($file->originalFilePath());
        
        preg_match(self::HEADER_PATTERN, $contents, $m);
        if (!$m) {
            return [[], $contents];
        }
        
        unset($contents);
        $lines      = file($file->originalFilePath(), FILE_IGNORE_NEW_LINES);
        $directives = [];
        
        foreach (preg_split('/\v/', $m[0]) as $lineNum => $line) {
            if (preg_match(self::DIRECTIVE_PATTERN, $line, $m)) {
                $dirValue = array_filter(explode(' ', $m[1]));
                $directives[] = [
                    'command'  => $dirValue[0],
                    'argument' => isset($dirValue[1]) ? $dirValue[1] : null,
                    'line'     => $lineNum + 1
                ];
                
                unset($lines[$lineNum]);
            }
        }
        
        return [$directives, implode("\n", $lines)];
    }
594470
public function filter(\SplFileInfo $file)
    {
        $content = file_get_contents($file);
        $result = preg_match_all('/class\s+([^\s|\{]+)[\s\{]/im', $content, $results, PREG_PATTERN_ORDER);
        unset($content);

        if (!$result) {
            return false;
        }

        if (count($results[0]) > 1) {
            return false;
        }

        return true;
    }
824436
public function init(\SplFileInfo $file, $extension = null)
    {
        $config = Grav::instance()['config'];

        // some extension logic
        if (empty($extension)) {
            $this->extension('.' . $file->getExtension());
        } else {
            $this->extension($extension);
        }

        // extract page language from page extension
        $language = trim(basename($this->extension(), 'md'), '.') ?: null;
        $this->language($language);

        $this->hide_home_route = $config->get('system.home.hide_in_urls', false);
        $this->home_route = $this->adjustRouteCase($config->get('system.home.alias'));
        $this->filePath($file->getPathname());
        $this->modified($file->getMTime());
        $this->id($this->modified() . md5($this->filePath()));
        $this->routable(true);
        $this->header();
        $this->date();
        $this->metadata();
        $this->url();
        $this->visible();
        $this->modularTwig(strpos($this->slug(), '_') === 0);
        $this->setPublishState();
        $this->published();
        $this->urlExtension();


        return $this;
    }
331472
private function extractFilePath($fileArgument)
    {
        // If the file argument was a variable, get it from the context
        if ($fileArgument !== null &&
            \strlen($fileArgument) > 0 &&
            $fileArgument[0] === '$') {
            $fileArgument = $this->context->get(\preg_replace('/^\$/', '', $fileArgument));
        }

        return $fileArgument;
    }