8000 fixed CS · symfony/symfony@7ee758c · GitHub
[go: up one dir, main page]

Skip to content

Commit 7ee758c

Browse files
committed
fixed CS
1 parent a8955bf commit 7ee758c

File tree

2 files changed

+18
-16
lines changed

2 files changed

+18
-16
lines changed

src/Symfony/Component/HttpKernel/Profiler/MongoDbProfilerStorage.php

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -99,18 +99,19 @@ public function write(Profile $profile)
9999
*/
100100
protected function getMongo()
101101
{
102-
if ($this->mongo === null) {
103-
if ($parsedDsn = $this->parseDsn($this->dsn)) {
104-
list($server, $database, $collection) = $parsedDsn;
105-
$mongoClass = (version_compare(phpversion('mongo'), '1.3.0', '<')) ? '\Mongo' : '\MongoClient';
106-
$mongo = new $mongoClass($server);
107-
$this->mongo = $mongo->selectCollection($database, $collection);
108-
} else {
109-
throw new \RuntimeException(sprintf('Please check your configuration. You are trying to use MongoDB with an invalid dsn "%s". The expected format is "mongodb://[user:pass@]host/database/collection"', $this->dsn));
110-
}
102+
if (null !== $this->mongo) {
103+
return $this->mongo;
104+
}
105+
106+
if (!$parsedDsn = $this->parseDsn($this->dsn)) {
107+
throw new \RuntimeException(sprintf('Please check your configuration. You are trying to use MongoDB with an invalid dsn "%s". The expected format is "mongodb://[user:pass@]host/database/collection"', $this->dsn));
111108
}
112109

113-
return $this->mongo;
110+
list($server, $database, $collection) = $parsedDsn;
111+
$mongoClass = version_compare(phpversion('mongo'), '1.3.0', '<') ? '\Mongo' : '\MongoClient';
112+
$mongo = new $mongoClass($server);
113+
114+
return $this->mongo = $mongo->selectCollection($database, $collection);
114115
}
115116

116117
/**
@@ -239,13 +240,15 @@ private function getProfile(array $data)
239240
private function parseDsn($dsn)
240241
{
241242
if (!preg_match('#^(mongodb://.*)/(.*)/(.*)$#', $dsn, $matches)) {
242-
return null;
243+
return;
243244
}
245+
244246
$server = $matches[1];
245247
$database = $matches[2];
246248
$collection = $matches[3];
247249
preg_match('#^mongodb://(([^:]+):?(.*)(?=@))?@?([^/]*)(.*)$#', $server, $matchesServer);
248-
if ($matchesServer[5]=="" && $matches[2]!="") {
250+
251+
if ('' == $matchesServer[5] && '' != $matches[2]) {
249252
$server .= '/'.$matches[2];
250253
}
251254

src/Symfony/Component/HttpKernel/Tests/Profiler/MongoDbProfilerStorageTest.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public static function tearDownAfterClass()
7171
}
7272
}
7373

74-
public function providerDsn()
74+
public function getDsns()
7575
{
7676
return array(
7777
array('mongodb://localhost/symfony_tests/profiler_data', array(
@@ -114,12 +114,11 @@ public function testCleanup()
114114
}
115115

116116
/**
117-
* @dataProvider providerDsn
117+
* @dataProvider getDsns
118118
*/
119119
public function testDsnParser($dsn, $expected)
120120
{
121-
$r=new \ReflectionObject(self::$storage);
122-
$m=$r->getMethod('parseDsn');
121+
$m = new \ReflectionMethod(self::$storage, 'parseDsn');
123122
$m->setAccessible(true);
124123

125124
$this->assertEquals($expected, $m->invoke(self::$storage, $dsn));

0 commit comments

Comments
 (0)
0