Skip to content

Commit c76f333

Browse files
committed
Work on Laravel 5.4 compatibility
1 parent e3bea54 commit c76f333

25 files changed

+532
-762
lines changed

src/Jenssegers/Mongodb/Auth/DatabaseTokenRepository.php

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,22 @@
11
<?php namespace Jenssegers\Mongodb\Auth;
22

3-
use Illuminate\Auth\Passwords\DatabaseTokenRepository as BaseDatabaseTokenRepository;
4-
use MongoDB\BSON\UTCDateTime;
53
use DateTime;
64
use DateTimeZone;
5+
use Illuminate\Auth\Passwords\DatabaseTokenRepository as BaseDatabaseTokenRepository;
6+
use MongoDB\BSON\UTCDateTime;
77

88
class DatabaseTokenRepository extends BaseDatabaseTokenRepository
99
{
1010
/**
11-
* Build the record payload for the table.
12-
*
13-
* @param string $email
14-
* @param string $token
15-
* @return array
11+
* @inheritdoc
1612
*/
1713
protected function getPayload($email, $token)
1814
{
1915
return ['email' => $email, 'token' => $token, 'created_at' => new UTCDateTime(round(microtime(true) * 1000))];
2016
}
2117

2218
/**
23-
* Determine if the token has expired.
24-
*
25-
* @param array $token
26-
* @return bool
19+
* @inheritdoc
2720
*/
2821
protected function tokenExpired($token)
2922
{

src/Jenssegers/Mongodb/Auth/PasswordBrokerManager.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@
55
class PasswordBrokerManager extends BasePasswordBrokerManager
66
{
77
/**
8-
* Create a token repository instance based on the given configuration.
9-
*
10-
* @param array $config
11-
* @return \Illuminate\Auth\Passwords\TokenRepositoryInterface
8+
* @inheritdoc
129
*/
1310
protected function createTokenRepository(array $config)
1411
{

src/Jenssegers/Mongodb/Auth/PasswordResetServiceProvider.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ protected function registerTokenRepository()
2828
}
2929

3030
/**
31-
* Register the password broker instance.
32-
*
33-
* @return void
31+
* @inheritdoc
3432
*/
3533
protected function registerPasswordBroker()
3634
{

src/Jenssegers/Mongodb/Collection.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?php namespace Jenssegers\Mongodb;
22

33
use Exception;
4-
use MongoDB\Collection as MongoCollection;
54
use MongoDB\BSON\ObjectID;
5+
use MongoDB\Collection as MongoCollection;
66

77
class Collection
88
{
@@ -21,7 +21,8 @@ class Collection
2121
protected $collection;
2222

2323
/**
24-
* Constructor.
24+
* @param Connection $connection
25+
* @param MongoCollection $collection
2526
*/
2627
public function __construct(Connection $connection, MongoCollection $collection)
2728
{
@@ -32,8 +33,8 @@ public function __construct(Connection $connection, MongoCollection $collection)
3233
/**
3334
* Handle dynamic method calls.
3435
*
35-
* @param string $method
36-
* @param array $parameters
36+
* @param string $method
37+
* @param array $parameters
3738
* @return mixed
3839
*/
3940
public function __call($method, $parameters)
@@ -65,7 +66,7 @@ public function __call($method, $parameters)
6566
}
6667
}
6768

68-
$queryString = $this->collection->getCollectionName() . '.' . $method . '(' . implode(',', $query) . ')';
69+
$queryString = $this->collection->getCollectionName().'.'.$method.'('.implode(',', $query).')';
6970

7071
$this->connection->logQuery($queryString, [], $time);
7172
}

src/Jenssegers/Mongodb/Connection.php

Lines changed: 20 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class Connection extends \Illuminate\Database\Connection
2121
/**
2222
* Create a new database connection instance.
2323
*
24-
* @param array $config
24+
* @param array $config
2525
*/
2626
public function __construct(array $config)
2727
{
@@ -45,9 +45,7 @@ public function __construct(array $config)
4545
}
4646

4747
/**
48-
* Get the default post processor instance.
49-
*
50-
* @return Query\Processor
48+
* @inheritdoc
5149
*/
5250
protected function getDefaultPostProcessor()
5351
{
@@ -57,7 +55,7 @@ protected function getDefaultPostProcessor()
5755
/**
5856
* Begin a fluent query against a database collection.
5957
*
60-
* @param string $collection
58+
* @param string $collection
6159
* @return Query\Builder
6260
*/
6361
public function collection($collection)
@@ -72,7 +70,7 @@ public function collection($collection)
7270
/**
7371
* Begin a fluent query against a database collection.
7472
*
75-
* @param string $table
73+
* @param string $table
7674
* @return Query\Builder
7775
*/
7876
public function table($table)
@@ -83,7 +81,7 @@ public function table($table)
8381
/**
8482
* Get a MongoDB collection.
8583
*
86-
* @param string $name
84+
* @param string $name
8785
* @return Collection
8886
*/
8987
public function getCollection($name)
@@ -92,9 +90,7 @@ public function getCollection($name)
9290
}
9391

9492
/**
95-
* Get a schema builder instance for the connection.
96-
*
97-
* @return Schema\Builder
93+
* @inheritdoc
9894
*/
9995
public function getSchemaBuilder()
10096
{
@@ -124,9 +120,9 @@ public function getMongoClient()
124120
/**
125121
* Create a new MongoDB connection.
126122
*
127-
* @param string $dsn
128-
* @param array $config
129-
* @param array $options
123+
* @param string $dsn
124+
* @param array $config
125+
* @param array $options
130126
* @return \MongoDB\Client
131127
*/
132128
protected function createConnection($dsn, array $config, array $options)
@@ -139,18 +135,18 @@ protected function createConnection($dsn, array $config, array $options)
139135
}
140136

141137
// Check if the credentials are not already set in the options
142-
if (!isset($options['username']) && !empty($config['username'])) {
138+
if (! isset($options['username']) && ! empty($config['username'])) {
143139
$options['username'] = $config['username'];
144140
}
145-
if (!isset($options['password']) && !empty($config['password'])) {
141+
if (! isset($options['password']) && ! empty($config['password'])) {
146142
$options['password'] = $config['password'];
147143
}
148144

149145
return new Client($dsn, $options, $driverOptions);
150146
}
151147

152148
/**
153-
* Disconnect from the underlying MongoDB connection.
149+
* @inheritdoc
154150
*/
155151
public function disconnect()
156152
{
@@ -160,7 +156,7 @@ public function disconnect()
160156
/**
161157
* Create a DSN string from a configuration.
162158
*
163-
* @param array $config
159+
* @param array $config
164160
* @return string
165161
*/
166162
protected function getDsn(array $config)
@@ -176,41 +172,34 @@ protected function getDsn(array $config)
176172
foreach ($hosts as &$host) {
177173
// Check if we need to add a port to the host
178174
if (strpos($host, ':') === false && ! empty($config['port'])) {
179-
$host = $host . ':' . $config['port'];
175+
$host = $host.':'.$config['port'];
180176
}
181177
}
182178

183179
// Check if we want to authenticate against a specific database.
184180
$auth_database = isset($config['options']) && ! empty($config['options']['database']) ? $config['options']['database'] : null;
185181

186-
return 'mongodb://' . implode(',', $hosts) . ($auth_database ? '/' . $auth_database : '');
182+
return 'mongodb://'.implode(',', $hosts).($auth_database ? '/'.$auth_database : '');
187183
}
188184

189185
/**
190-
* Get the elapsed time since a given starting point.
191-
*
192-
* @param int $start
193-
* @return float
186+
* @inheritdoc
194187
*/
195188
public function getElapsedTime($start)
196189
{
197190
return parent::getElapsedTime($start);
198191
}
199192

200193
/**
201-
* Get the PDO driver name.
202-
*
203-
* @return string
194+
* @inheritdoc
204195
*/
205196
public function getDriverName()
206197
{
207198
return 'mongodb';
208199
}
209200

210201
/**
211-
* Get the default schema grammar instance.
212-
*
213-
* @return Schema\Grammar
202+
* @inheritdoc
214203
*/
215204
protected function getDefaultSchemaGrammar()
216205
{
@@ -220,8 +209,8 @@ protected function getDefaultSchemaGrammar()
220209
/**
221210
* Dynamically pass methods to the connection.
222211
*
223-
* @param string $method
224-
* @param array $parameters
212+
* @param string $method
213+
* @param array $parameters
225214
* @return mixed
226215
*/
227216
public function __call($method, $parameters)

0 commit comments

Comments
 (0)