Conditions | 4 |
Paths | 3 |
Total Lines | 30 |
Code Lines | 20 |
Lines | 0 |
Ratio | 0 % |
Tests | 19 |
CRAP Score | 4 |
Changes | 0 |
1 | <?php |
||
82 | 4 | public function getConnectionUri(string $databaseName = null): string |
|
83 | { |
||
84 | // Refactor with a uriBuilder service or something like that |
||
85 | 4 | if ($this->hasCredentials() && !is_null($databaseName)) { |
|
86 | 2 | return sprintf( |
|
87 | 2 | 'mongodb://%s:%s@%s:%d/%s', |
|
88 | 2 | $this->username, |
|
89 | 2 | $this->password, |
|
90 | 2 | $this->host, |
|
91 | 2 | $this->port, |
|
92 | $databaseName |
||
93 | ); |
||
94 | } |
||
95 | |||
96 | 2 | if ($this->hasCredentials()) { |
|
97 | 1 | return sprintf( |
|
98 | 1 | 'mongodb://%s:%s@%s:%d', |
|
99 | 1 | $this->username, |
|
100 | 1 | $this->password, |
|
101 | 1 | $this->host, |
|
102 | 1 | $this->port |
|
103 | ); |
||
104 | } |
||
105 | |||
106 | 1 | return sprintf( |
|
107 | 1 | 'mongodb://%s:%d', |
|
108 | 1 | $this->host, |
|
109 | 1 | $this->port |
|
110 | ); |
||
111 | } |
||
112 | } |
||
113 |