Lines Matching refs:dsn

29      * string, then a "dsn()" function will be added.
33 public static function parseFunc(string $dsn): DsnFunction
37 if (1 === preg_match(self::FUNCTION_REGEX, $dsn, $matches)) {
42 $functionName = 'dsn';
43 $arguments = $dsn;
47 throw new SyntaxException($dsn, 'dsn' === $functionName ? 'The DSN is empty' : 'A function must have arguments, an empty string was provided.');
64 public static function parse(string $dsn): Dsn
66 if (1 === preg_match(self::FUNCTION_REGEX, $dsn, $matches)) {
67 if ('dsn' === $matches[1]) {
70 throw new FunctionsNotAllowedException($dsn);
73 return self::getDsn($dsn);
76 public static function parseUrl(string $dsn): Url
78 $dsn = self::parse($dsn);
79 if (!$dsn instanceof Url) {
80 throw DsnTypeNotSupported::onlyUrl($dsn);
83 return $dsn;
86 public static function parsePath(string $dsn): Path
88 $dsn = self::parse($dsn);
89 if (!$dsn instanceof Path) {
90 throw DsnTypeNotSupported::onlyPath($dsn);
93 return $dsn;
99 private static function parseArguments(string $dsn)
102 if (1 === preg_match(self::FUNCTION_REGEX, $dsn)) {
103 return self::parseFunc($dsn);
106 // Assert: $dsn does not contain any functions.
107 return self::getDsn($dsn);
113 private static function getDsn(string $dsn): Dsn
116 if (!preg_match('#^(?:(?<alt>['.self::UNRESERVED.self::SUB_DELIMS.'%]+:[0-9]+(?:[/?].*)?)|(?<scheme>[a-zA-Z0-9\+-\.]+):(?://)?(?<dsn>.*))$#', $dsn, $matches)) {
117 throw new SyntaxException($dsn, 'A DSN must contain a scheme [a-zA-Z0-9\+-\.]+ and a colon.');
120 $dsn = $matches['alt'];
123 $dsn = $matches['dsn'];
126 if ('' === $dsn) {
131 if (!preg_match('#^(?:(['.self::UNRESERVED.self::SUB_DELIMS.'%]+)?(?::(['.self::UNRESERVED.self::SUB_DELIMS.'%]*))?@)?([^\s@]+)$#', $dsn, $matches)) {
132 throw new SyntaxException($dsn, 'The provided DSN is not valid. Maybe you need to url-encode the user/password?');
141 $parts = self::explodeUrl('http://localhost'.$matches[3], $dsn);
147 $parts = self::explodeUrl($matches[3], $dsn);
152 $parts = self::explodeUrl('http://'.$matches[3], $dsn);
162 private static function explodeUrl(string $url, string $dsn): array
166 throw new SyntaxException($dsn, 'The provided DSN is not valid.');