Jackalope\Transport\DoctrineDBAL\Client::registerSqliteFunctions PHP Method

registerSqliteFunctions() private method

private registerSqliteFunctions ( PDO $sqliteConnection ) : Client
$sqliteConnection PDO
return Client
    private function registerSqliteFunctions(\PDO $sqliteConnection)
    {
        $sqliteConnection->sqliteCreateFunction('EXTRACTVALUE', function ($string, $expression) {
            if (null === $string) {
                return null;
            }
            $dom = new \DOMDocument('1.0', 'UTF-8');
            $dom->loadXML($string);
            $xpath = new \DOMXPath($dom);
            $list = $xpath->evaluate($expression);
            if (!is_object($list)) {
                return $list;
            }
            // @TODO: don't know if there are expressions returning more then one row
            if ($list->length > 0) {
                // @TODO: why it can happen that we do not have a type? https://github.com/phpcr/phpcr-api-tests/pull/132
                $type = is_object($list->item(0)->parentNode->attributes->getNamedItem('type')) ? $list->item(0)->parentNode->attributes->getNamedItem('type')->value : null;
                $content = $list->item(0)->textContent;
                switch ($type) {
                    case 'long':
                        return (int) $content;
                        break;
                    case 'double':
                        return (double) $content;
                        break;
                    default:
                        return $content;
                }
            }
            // @TODO: don't know if return value is right
            return null;
        }, 2);
        $sqliteConnection->sqliteCreateFunction('CONCAT', function () {
            return implode('', func_get_args());
        });
        return $this;
    }