@@ -28,21 +28,21 @@ roundrobin(dummy://a failover(dummy://b dummy://a) dummy://b)
28
28
29
29
## Parsing
30
30
31
- There are two methods for parsing; ` DsnParser::parse() ` and ` DsnParser::parseSimple () ` .
32
- The latter is useful in situations where DSN functions are not needed .
31
+ There are two methods for parsing; ` DsnParser::parse() ` and ` DsnParser::parseFunc () ` .
32
+ The latter is for in situations where DSN functions are supported .
33
33
34
34
``` php
35
- $dsn = DsnParser::parseSimple ('scheme://127.0.0.1/foo/bar?key=value');
35
+ $dsn = DsnParser::parse ('scheme://127.0.0.1/foo/bar?key=value');
36
36
echo get_class($dsn); // "Symfony\Component\Dsn\Configuration\Url"
37
37
echo $dsn->getHost(); // "127.0.0.1"
38
38
echo $dsn->getPath(); // "/foo/bar"
39
39
echo $dsn->getPort(); // null
40
40
```
41
41
42
- If functions are supported (like in the Mailer component) we can use ` DsnParser::parse () ` :
42
+ If functions are supported (like in the Mailer component) we can use ` DsnParser::parseFunc () ` :
43
43
44
44
``` php
45
- $func = DsnParser::parse ('failover(sendgrid://KEY@default smtp://127.0.0.1)');
45
+ $func = DsnParser::parseFunc ('failover(sendgrid://KEY@default smtp://127.0.0.1)');
46
46
echo $func->getName(); // "failover"
47
47
echo get_class($func->first()); // "Symfony\Component\Dsn\Configuration\Url"
48
48
echo $func->first()->getHost(); // "default"
@@ -51,7 +51,7 @@ echo $func->first()->getUser(); // "KEY"
51
51
52
52
``` php
53
53
54
- $func = DsnParser::parse ('foo(udp://localhost failover:(tcp://localhost:61616,tcp://remotehost:61616)?initialReconnectDelay=100)?start=now');
54
+ $func = DsnParser::parseFunc ('foo(udp://localhost failover:(tcp://localhost:61616,tcp://remotehost:61616)?initialReconnectDelay=100)?start=now');
55
55
echo $func->getName(); // "foo"
56
56
echo $func->getParameters()['start']; // "now"
57
57
$args = $func->getArguments();
@@ -62,21 +62,21 @@ echo $args[0]->getHost(); // "localhost"
62
62
echo get_class($args[1]); // "Symfony\Component\Dsn\Configuration\DsnFunction"
63
63
```
64
64
65
- When using ` DsnParser::parse () ` on a string that does not contain any DSN functions,
65
+ When using ` DsnParser::parseFunc () ` on a string that does not contain any DSN functions,
66
66
the parser will automatically add a default "dsn" function. This is added to provide
67
67
a consistent return type of the method.
68
68
69
69
The string ` redis://127.0.0.1 ` will automatically be converted to ` dsn(redis://127.0.0.1) `
70
- when using ` DsnParser::parse () ` .
70
+ when using ` DsnParser::parseFunc () ` .
71
71
72
72
``` php
73
- $func = DsnParser::parse ('smtp://127.0.0.1');
73
+ $func = DsnParser::parseFunc ('smtp://127.0.0.1');
74
74
echo $func->getName(); // "dsn"
75
75
echo get_class($func->first()); // "Symfony\Component\Dsn\Configuration\Url"
76
76
echo $func->first()->getHost(); // "127.0.0.1"
77
77
78
78
79
- $func = DsnParser::parse ('dsn(smtp://127.0.0.1)');
79
+ $func = DsnParser::parseFunc ('dsn(smtp://127.0.0.1)');
80
80
echo $func->getName(); // "dsn"
81
81
echo get_class($func->first()); // "Symfony\Component\Dsn\Configuration\Url"
82
82
echo $func->first()->getHost(); // "127.0.0.1"
0 commit comments