Skip to content

Commit 13859bb

Browse files
committed
Add styleci
1 parent 52145b0 commit 13859bb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+2700
-2687
lines changed

.styleci.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
preset: psr2
2+
3+
enabled:
4+
- duplicate_semicolon
5+
- empty_return
6+
- extra_empty_lines
7+
- operators_spaces
8+
- phpdoc_indent
9+
- remove_leading_slash_use
10+
- spaces_cast
11+
- ternary_spaces
12+
- unused_use
13+
14+
disabled:
15+
- braces
16+
- parenthesis

src/Jenssegers/Eloquent/Model.php

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313
abstract class Model extends \Illuminate\Database\Eloquent\Model {
1414

1515
/**
16-
* Define a one-to-one relationship.
17-
*
18-
* @param string $related
19-
* @param string $foreignKey
20-
* @param string $localKey
21-
* @return \Illuminate\Database\Eloquent\Relations\HasOne
22-
*/
16+
* Define a one-to-one relationship.
17+
*
18+
* @param string $related
19+
* @param string $foreignKey
20+
* @param string $localKey
21+
* @return \Illuminate\Database\Eloquent\Relations\HasOne
22+
*/
2323
public function hasOne($related, $foreignKey = null, $localKey = null)
2424
{
2525
// Check if it is a relation with an original model.
@@ -67,13 +67,13 @@ public function morphOne($related, $name, $type = null, $id = null, $localKey =
6767
}
6868

6969
/**
70-
* Define a one-to-many relationship.
71-
*
72-
* @param string $related
73-
* @param string $foreignKey
74-
* @param string $localKey
75-
* @return \Illuminate\Database\Eloquent\Relations\HasMany
76-
*/
70+
* Define a one-to-many relationship.
71+
*
72+
* @param string $related
73+
* @param string $foreignKey
74+
* @param string $localKey
75+
* @return \Illuminate\Database\Eloquent\Relations\HasMany
76+
*/
7777
public function hasMany($related, $foreignKey = null, $localKey = null)
7878
{
7979
// Check if it is a relation with an original model.
@@ -124,14 +124,14 @@ public function morphMany($related, $name, $type = null, $id = null, $localKey =
124124
}
125125

126126
/**
127-
* Define an inverse one-to-one or many relationship.
128-
*
129-
* @param string $related
130-
* @param string $foreignKey
131-
* @param string $otherKey
132-
* @param string $relation
133-
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
134-
*/
127+
* Define an inverse one-to-one or many relationship.
128+
*
129+
* @param string $related
130+
* @param string $foreignKey
131+
* @param string $otherKey
132+
* @param string $relation
133+
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
134+
*/
135135
public function belongsTo($related, $foreignKey = null, $otherKey = null, $relation = null)
136136
{
137137
// If no relation name was given, we will use this debug backtrace to extract

src/Jenssegers/Mongodb/Auth/DatabaseTokenRepository.php

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -5,37 +5,37 @@
55

66
class DatabaseTokenRepository extends \Illuminate\Auth\Passwords\DatabaseTokenRepository {
77

8-
/**
9-
* Build the record payload for the table.
10-
*
11-
* @param string $email
12-
* @param string $token
13-
* @return array
14-
*/
15-
protected function getPayload($email, $token)
16-
{
17-
return ['email' => $email, 'token' => $token, 'created_at' => new MongoDate];
18-
}
19-
20-
/**
21-
* Determine if the token has expired.
22-
*
23-
* @param array $token
24-
* @return bool
25-
*/
26-
protected function tokenExpired($token)
27-
{
28-
// Convert MongoDate to a date string.
29-
if ($token['created_at'] instanceof MongoDate)
30-
{
31-
$date = new DateTime;
32-
33-
$date->setTimestamp($token['created_at']->sec);
34-
35-
$token['created_at'] = $date->format('Y-m-d H:i:s');
36-
}
37-
38-
return parent::tokenExpired($token);
39-
}
8+
/**
9+
* Build the record payload for the table.
10+
*
11+
* @param string $email
12+
* @param string $token
13+
* @return array
14+
*/
15+
protected function getPayload($email, $token)
16+
{
17+
return ['email' => $email, 'token' => $token, 'created_at' => new MongoDate];
18+
}
19+
20+
/**
21+
* Determine if the token has expired.
22+
*
23+
* @param array $token
24+
* @return bool
25+
*/
26+
protected function tokenExpired($token)
27+
{
28+
// Convert MongoDate to a date string.
29+
if ($token['created_at'] instanceof MongoDate)
30+
{
31+
$date = new DateTime;
32+
33+
$date->setTimestamp($token['created_at']->sec);
34+
35+
$token['created_at'] = $date->format('Y-m-d H:i:s');
36+
}
37+
38+
return parent::tokenExpired($token);
39+
}
4040

4141
}

src/Jenssegers/Mongodb/Auth/PasswordResetServiceProvider.php

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,26 @@
44

55
class PasswordResetServiceProvider extends \Illuminate\Auth\Passwords\PasswordResetServiceProvider {
66

7-
/**
8-
* Register the token repository implementation.
9-
*
10-
* @return void
11-
*/
12-
protected function registerTokenRepository()
13-
{
14-
$this->app->singleton('auth.password.tokens', function($app)
15-
{
16-
$connection = $app['db']->connection();
7+
/**
8+
* Register the token repository implementation.
9+
*
10+
* @return void
11+
*/
12+
protected function registerTokenRepository()
13+
{
14+
$this->app->singleton('auth.password.tokens', function ($app)
15+
{
16+
$connection = $app['db']->connection();
1717

18-
// The database token repository is an implementation of the token repository
19-
// interface, and is responsible for the actual storing of auth tokens and
20-
// their e-mail addresses. We will inject this table and hash key to it.
21-
$table = $app['config']['auth.password.table'];
22-
$key = $app['config']['app.key'];
23-
$expire = $app['config']->get('auth.password.expire', 60);
18+
// The database token repository is an implementation of the token repository
19+
// interface, and is responsible for the actual storing of auth tokens and
20+
// their e-mail addresses. We will inject this table and hash key to it.
21+
$table = $app['config']['auth.password.table'];
22+
$key = $app['config']['app.key'];
23+
$expire = $app['config']->get('auth.password.expire', 60);
2424

25-
return new DbRepository($connection, $table, $key, $expire);
26-
});
27-
}
25+
return new DbRepository($connection, $table, $key, $expire);
26+
});
27+
}
2828

2929
}

src/Jenssegers/Mongodb/Collection.php

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

3-
use Exception, MongoCollection;
4-
use Jenssegers\Mongodb\Connection;
3+
use Exception;
4+
use MongoCollection;
55

66
class Collection {
77

@@ -63,7 +63,7 @@ public function __call($method, $parameters)
6363
}
6464
}
6565

66-
$queryString = $this->collection->getName() . '.' . $method . '(' . join(',', $query) . ')';
66+
$queryString = $this->collection->getName() . '.' . $method . '(' . implode(',', $query) . ')';
6767

6868
$this->connection->logQuery($queryString, [], $time);
6969
}

src/Jenssegers/Mongodb/Connection.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public function getMongoDB()
111111
}
112112

113113
/**
114-
* return MongoClient object
114+
* return MongoClient object.
115115
*
116116
* @return MongoClient
117117
*/
@@ -211,10 +211,10 @@ public function getElapsedTime($start)
211211
}
212212

213213
/**
214-
* Get the PDO driver name.
215-
*
216-
* @return string
217-
*/
214+
* Get the PDO driver name.
215+
*
216+
* @return string
217+
*/
218218
public function getDriverName()
219219
{
220220
return 'mongodb';

src/Jenssegers/Mongodb/Eloquent/Builder.php

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class Builder extends EloquentBuilder {
1313
*/
1414
protected $passthru = array(
1515
'toSql', 'lists', 'insert', 'insertGetId', 'pluck',
16-
'count', 'min', 'max', 'avg', 'sum', 'exists', 'push', 'pull'
16+
'count', 'min', 'max', 'avg', 'sum', 'exists', 'push', 'pull',
1717
);
1818

1919
/**
@@ -174,7 +174,7 @@ protected function addHasWhere(EloquentBuilder $hasQuery, Relation $relation, $o
174174
$relationCount = array_count_values($query->lists($relation->getHasCompareKey()));
175175

176176
// Remove unwanted related objects based on the operator and count.
177-
$relationCount = array_filter($relationCount, function($counted) use ($count, $operator)
177+
$relationCount = array_filter($relationCount, function ($counted) use ($count, $operator)
178178
{
179179
// If we are comparing to 0, we always need all results.
180180
if ($count == 0) return true;
@@ -213,29 +213,29 @@ protected function addHasWhere(EloquentBuilder $hasQuery, Relation $relation, $o
213213
* @return mixed
214214
*/
215215
public function raw($expression = null)
216-
{
217-
// Get raw results from the query builder.
218-
$results = $this->query->raw($expression);
216+
{
217+
// Get raw results from the query builder.
218+
$results = $this->query->raw($expression);
219219

220-
// Convert MongoCursor results to a collection of models.
221-
if ($results instanceof MongoCursor)
222-
{
223-
$results = iterator_to_array($results, false);
220+
// Convert MongoCursor results to a collection of models.
221+
if ($results instanceof MongoCursor)
222+
{
223+
$results = iterator_to_array($results, false);
224224

225-
return $this->model->hydrate($results);
226-
}
225+
return $this->model->hydrate($results);
226+
}
227227

228-
// The result is a single object.
229-
else if (is_array($results) and array_key_exists('_id', $results))
230-
{
231-
$model = $this->model->newFromBuilder($results);
228+
// The result is a single object.
229+
elseif (is_array($results) and array_key_exists('_id', $results))
230+
{
231+
$model = $this->model->newFromBuilder($results);
232232

233-
$model->setConnection($this->model->getConnection());
233+
$model->setConnection($this->model->getConnection());
234234

235-
return $model;
236-
}
235+
return $model;
236+
}
237237

238-
return $results;
239-
}
238+
return $results;
239+
}
240240

241241
}

src/Jenssegers/Mongodb/Eloquent/Collection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function where($key, $operator = null, $value = null)
4040
list($value, $operator) = array($operator, '=');
4141
}
4242

43-
return $this->filter(function($item) use ($key, $operator, $value)
43+
return $this->filter(function ($item) use ($key, $operator, $value)
4444
{
4545
$actual = $item->{$key};
4646

src/Jenssegers/Mongodb/Eloquent/SoftDeletes.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22

33
trait SoftDeletes {
44

5-
use \Illuminate\Database\Eloquent\SoftDeletes;
5+
use \Illuminate\Database\Eloquent\SoftDeletes;
66

7-
/**
8-
* Get the fully qualified "deleted at" column.
9-
*
10-
* @return string
11-
*/
12-
public function getQualifiedDeletedAtColumn()
13-
{
14-
return $this->getDeletedAtColumn();
15-
}
7+
/**
8+
* Get the fully qualified "deleted at" column.
9+
*
10+
* @return string
11+
*/
12+
public function getQualifiedDeletedAtColumn()
13+
{
14+
return $this->getDeletedAtColumn();
15+
}
1616

1717
}

src/Jenssegers/Mongodb/Model.php

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

3-
use DateTime, MongoId, MongoDate, Carbon\Carbon;
3+
use DateTime;
4+
use MongoId;
5+
use MongoDate;
6+
use Carbon\Carbon;
47
use Illuminate\Database\Eloquent\Relations\Relation;
5-
use Jenssegers\Mongodb\DatabaseManager as Resolver;
68
use Jenssegers\Mongodb\Eloquent\Builder;
79
use Jenssegers\Mongodb\Relations\EmbedsOneOrMany;
810
use Jenssegers\Mongodb\Relations\EmbedsMany;
@@ -63,10 +65,9 @@ public function getIdAttribute($value)
6365
*/
6466
public function getQualifiedKeyName()
6567
{
66-
return $this->getKeyName();
68+
return $this->getKeyName();
6769
}
6870

69-
7071
/**
7172
* Define an embedded one-to-many relationship.
7273
*
@@ -306,7 +307,9 @@ public function setAttribute($key, $value)
306307
$value = $this->fromDateTime($value);
307308
}
308309

309-
array_set($this->attributes, $key, $value); return;
310+
array_set($this->attributes, $key, $value);
311+
312+
return;
310313
}
311314

312315
parent::setAttribute($key, $value);

0 commit comments

Comments
 (0)